home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / GameCreators / TADS / library / adv.t next >
Encoding:
Text File  |  1997-03-15  |  115.3 KB  |  4,289 lines

  1. /* Copyright (c) 1988, 1994 by Michael J. Roberts.  All Rights Reserved. */
  2. /*
  3.    adv.t  - standard adventure definitions for TADS games
  4.    Version 2.2 with correction to showcontcont routine to enable objects
  5.    on 'surfaces' to appear in room descriptions, in accordance with the
  6.    manuals.
  7.  
  8.    This file is part of TADS:  The Text Adventure Development System.
  9.    Please see the file LICENSE.DOC (which should be part of the TADS
  10.    distribution) for information on using this file.
  11.  
  12.    This file defines the basic classes and functions used by most TADS
  13.    adventure games.  It is generally #include'd at the start of each game
  14.    source file.
  15.  
  16. */
  17.  
  18. /* parse adv.t using normal TADS operators */
  19. #pragma C-
  20.  
  21. /*
  22.  *   Define compound prepositions.  Since prepositions that appear in
  23.  *   parsed sentences must be single words, we must define any logical
  24.  *   prepositions that consist of two or more words here.  Note that
  25.  *   only two words can be pasted together at once; to paste more, use
  26.  *   a second step.  For example,  'out from under' must be defined in
  27.  *   two steps:
  28.  *
  29.  *     compoundWord 'out' 'from' 'outfrom';
  30.  *     compoundWord 'outfrom' 'under' 'outfromunder';
  31.  *
  32.  *   Listed below are the compound prepositions that were built in to
  33.  *   version 1.0 of the TADS run-time.
  34.  */
  35. compoundWord 'on' 'to' 'onto';           /* on to --> onto */
  36. compoundWord 'in' 'to' 'into';           /* in to --> into */
  37. compoundWord 'in' 'between' 'inbetween'; /* and so forth */
  38. compoundWord 'down' 'in' 'downin';
  39. compoundWord 'down' 'on' 'downon';
  40. compoundWord 'up' 'on' 'upon';
  41. compoundWord 'out' 'of' 'outof';
  42. compoundWord 'off' 'of' 'offof';
  43. ;
  44.  
  45. /*
  46.  *   Format strings:  these associate keywords with properties.  When
  47.  *   a keyword appears in output between percent signs (%), the matching
  48.  *   property of the current command's actor is evaluated and substituted
  49.  *   for the keyword (and the percent signs).  For example, if you have:
  50.  *
  51.  *      formatstring 'you' fmtYou;
  52.  *
  53.  *   and the command being processed is:
  54.  *
  55.  *      fred, pick up the paper
  56.  *
  57.  *   and the "fred" actor has fmtYou = "he", and this string is output:
  58.  *
  59.  *      "%You% can't see that here."
  60.  *
  61.  *   Then the actual output is:  "He can't see that here."
  62.  *
  63.  *   The format strings are chosen to look like normal output (minus the
  64.  *   percent signs, of course) when the actor is Me.
  65.  */
  66. formatstring 'you' fmtYou;
  67. formatstring 'your' fmtYour;
  68. formatstring 'you\'re' fmtYoure;
  69. formatstring 'youm' fmtYoum;
  70. formatstring 'you\'ve' fmtYouve;
  71. formatstring 's' fmtS;
  72. formatstring 'es' fmtEs;
  73. formatstring 'have' fmtHave;
  74. formatstring 'do' fmtDo;
  75. formatstring 'are' fmtAre;
  76. formatstring 'me' fmtMe;
  77. ;
  78.  
  79. /*
  80.  *   Special Word List: This list defines the special words that the
  81.  *   parser needs for input commands.  If the list is not provided, the
  82.  *   parser uses the old defaults.  The list below is the same as the old
  83.  *   defaults.  Note - the words in this list must appear in the order
  84.  *   shown below.
  85.  */
  86. specialWords
  87.     'of',                        /* used in phrases such as "piece of paper" */
  88.     'and',             /* conjunction for noun lists or to separate commands */
  89.     'then',                              /* conjunction to separate commands */
  90.     'all' = 'everything',               /* refers to every accessible object */
  91.     'both',      /* used with plurals, or to answer disambiguation questions */
  92.     'but' = 'except',                      /* used to exclude items from ALL */
  93.     'one',                       /* used to answer questions:  "the red one" */
  94.     'ones',                        /* likewise for plurals:  "the blue ones" */
  95.     'it' = 'there',              /* refers to last single direct object used */
  96.     'them',                             /* refers to last direct object list */
  97.     'him',                       /* refers to last masculine actor mentioned */
  98.     'her',                        /* refers to last feminine actor mentioned */
  99.     'any' = 'either'         /* pick object arbitrarily from ambiguous list */
  100. ;
  101.  
  102. /*
  103.  *   Forward-declare functions.  This is not required in most cases,
  104.  *   but it doesn't hurt.  Providing these forward declarations ensures
  105.  *   that the compiler knows that we want these symbols to refer to
  106.  *   functions rather than objects.
  107.  */
  108. checkDoor: function;
  109. checkReach: function;
  110. itemcnt: function;
  111. isIndistinguishable: function;
  112. sayPrefixCount: function;
  113. listcont: function;
  114. listcontcont: function;
  115. turncount: function;
  116. addweight: function;
  117. addbulk: function;
  118. incscore: function;
  119. darkTravel: function;
  120. scoreRank: function;
  121. terminate: function;
  122. goToSleep: function;
  123. initSearch: function;
  124. reachableList: function;
  125. initRestart: function;
  126. ;
  127.  
  128. /*
  129.  *   initRestart - flag when a restart has occurred by setting a flag
  130.  *   in global.
  131.  */
  132. initRestart: function(parm)
  133. {
  134.     global.restarting := true;
  135. }
  136.  
  137. /*
  138.  *   checkDoor:  if the door d is open, this function silently returns
  139.  *   the room r.  Otherwise, print a message ("The door is closed.") and
  140.  *   return nil.
  141.  */
  142. checkDoor: function( d, r )
  143. {
  144.     if ( d.isopen ) return( r );
  145.     else
  146.     {
  147.     setit( d );
  148.     caps(); d.thedesc; " is closed. ";
  149.     return( nil );
  150.     }
  151. }
  152.  
  153. /*
  154.  *   checkReach: determines whether the object obj can be reached by
  155.  *   actor in location loc, using the verb v.  This routine returns true
  156.  *   if obj is a special object (numObj or strObj), if obj is in actor's
  157.  *   inventory or actor's location, or if it's in the 'reachable' list for
  158.  *   loc.  
  159.  */
  160. checkReach: function( loc, actor, v, obj )
  161. {
  162.     if ( obj=numObj or obj=strObj ) return;
  163.     if ( not ( actor.isCarrying( obj ) or obj.isIn( actor.location )))
  164.     {
  165.     if (find( loc.reachable, obj ) <> nil ) return;
  166.     "%You% can't reach "; obj.thedesc; " from "; loc.thedesc; ". ";
  167.     exit;
  168.     }
  169. }
  170.  
  171. /*
  172.  *  isIndistinguishable: function(obj1, obj2)
  173.  *
  174.  *  Returns true if the two objects are indistinguishable for the purposes
  175.  *  of listing.  The two objects are equivalent if they both have the
  176.  *  isEquivalent property set to true, they both have the same immediate
  177.  *  superclass, and their other listing properties match (in particular,
  178.  *  isworn and (islamp and islit) match for both objects).
  179.  */
  180. isIndistinguishable: function(obj1, obj2)
  181. {
  182.     return (firstsc(obj1) = firstsc(obj2)
  183.             and obj1.isworn = obj2.isworn
  184.             and ((obj1.islamp and obj1.islit)
  185.                  = (obj2.islamp and obj2.islit)));
  186. }
  187.  
  188.  
  189. /*
  190.  *  itemcnt: function( list )
  191.  *
  192.  *  Returns a count of the "listable" objects in list.  An
  193.  *  object is listable (that is, it shows up in a room's description)
  194.  *  if its isListed property is true.  This function is
  195.  *  useful for determining how many objects (if any) will be listed
  196.  *  in a room's description.  Indistinguishable items are counted as
  197.  *  a single item (two items are indistinguishable if they both have
  198.  *  the same immediate superclass, and their isEquivalent properties
  199.  *  are both true.
  200.  */
  201. itemcnt: function( list )
  202. {
  203.     local cnt, tot, i, obj, j;
  204.     tot := length(list);
  205.     cnt := 0;
  206.     i := 1;
  207.     for (i := 1, cnt := 0 ; i <= tot ; ++i)
  208.     {
  209.     /* only consider this item if it's to be listed */
  210.     obj := list[i];
  211.     if (obj.isListed)
  212.     {
  213.         /*
  214.          *   see if there are other equivalent items later in the
  215.          *   list - if so, don't count it (this ensures that each such
  216.          *   item is counted only once, since only the last such item
  217.          *   in the list will be counted) 
  218.          */
  219.         if (obj.isEquivalent)
  220.         {
  221.         local sc;
  222.         
  223.         sc := firstsc(obj);
  224.         for (j := i + 1 ; j <= tot ; ++j)
  225.         {
  226.             if (isIndistinguishable(obj, list[j]))
  227.             goto skip_this_item;
  228.         }
  229.         }
  230.         
  231.         /* count this item */
  232.         ++cnt;
  233.  
  234.     skip_this_item: ;
  235.     }
  236.     }
  237.     return cnt;
  238. }
  239.  
  240. /*
  241.  *  sayPrefixCount: function( cnt )
  242.  *
  243.  *  This function displays a count (suitable for use in listcont when
  244.  *  showing the number of equivalent items.  We display the count spelled out
  245.  *  if it's a small number, otherwise we just display the digits of the
  246.  *  number.
  247.  */
  248. sayPrefixCount: function(cnt)
  249. {
  250.     if (cnt <= 20)
  251.     say(['one' 'two' 'three' 'four' 'five'
  252.          'six' 'seven' 'eight' 'nine' 'ten'
  253.          'eleven' 'twelve' 'thirteen' 'fourteen' 'fifteen'
  254.          'sixteen' 'seventeen' 'eighteen' 'nineteen' 'twenty'][cnt]);
  255.     else
  256.     say(cnt);
  257. }
  258.  
  259. /*
  260.  *  listcont: function( obj )
  261.  *
  262.  *  This function displays the contents of an object, separated by
  263.  *  commas.  The thedesc properties of the contents are used.
  264.  *  It is up to the caller to provide the introduction to the list
  265.  *  (usually something to the effect of "The box contains" is
  266.  *  displayed before calling listcont) and finishing the
  267.  *  sentence (usually by displaying a period).  An object is listed
  268.  *  only if its isListed property is true.  If there are
  269.  *  multiple indistinguishable items in the list, the items are
  270.  *  listed only once (with the number of the items).
  271.  */
  272. listcont: function( obj )
  273. {
  274.     local i, count, tot, list, cur, disptot, prefix_count;
  275.  
  276.     list := obj.contents;
  277.     tot := length( list );
  278.     count := 0;
  279.     disptot := itemcnt( list );
  280.     for (i := 1 ; i <= tot ; ++i)
  281.     {
  282.         cur := list[i];
  283.         if ( cur.isListed )
  284.         {
  285.         /* presume there is only one such object */
  286.         prefix_count := 1;
  287.         
  288.         /*
  289.          *   if this is one of more than one equivalent items, list
  290.          *   it only if it's the first one, and show the number of
  291.          *   such items along with the first one 
  292.          */
  293.         if (cur.isEquivalent)
  294.         {
  295.         local before, after;
  296.         local j;
  297.         local sc;
  298.  
  299.         sc := firstsc(cur);
  300.         for (before := after := 0, j := 1 ; j <= tot ; ++j)
  301.         {
  302.             if (isIndistinguishable(cur, list[j]))
  303.             {
  304.             if (j < i)
  305.             {
  306.                 /*
  307.                  *   note that objects precede this one, and
  308.                  *   then look no further, since we're just
  309.                  *   going to skip this item anyway
  310.                  */
  311.                 ++before;
  312.                 break;
  313.             }
  314.             else
  315.                 ++after;
  316.             }
  317.         }
  318.  
  319.         /*
  320.          *   if there are multiple such objects, and this is the
  321.          *   first such object, list it with the count prefixed;
  322.          *   if there are multiple and this isn't the first one,
  323.          *   skip it; otherwise, go on as normal 
  324.          */
  325.         if (before = 0)
  326.             prefix_count := after;
  327.         else
  328.             continue;
  329.         }
  330.  
  331.             if ( count > 0 )
  332.             {
  333.                 if ( count+1 < disptot )
  334.                     ", ";
  335.                 else if (count = 1)
  336.                     " and ";
  337.                 else
  338.                     ", and ";
  339.             }
  340.  
  341.         /* list the object, along with the number of such items */
  342.         if (prefix_count = 1)
  343.         cur.adesc;
  344.         else
  345.         {
  346.         sayPrefixCount(prefix_count); " ";
  347.         cur.pluraldesc;
  348.         }
  349.  
  350.         /* show any additional information about the item */
  351.             if ( cur.isworn ) " (being worn)";
  352.             if ( cur.islamp and cur.islit ) " (providing light)";
  353.             count := count + 1;
  354.         }
  355.     }
  356. }
  357.  
  358. /*
  359.  *   showcontcont:  list the contents of the object, plus the contents of
  360.  *   an fixeditem's contained by the object.  A complete sentence is shown.
  361.  *   This is an internal routine used by listcontcont and listfixedcontcont.
  362.  */
  363. showcontcont: function( obj )
  364. {
  365.     if (itemcnt( obj.contents ))
  366.     {
  367.         if (obj.issurface)
  368.         {
  369.         if (not obj.isqsurface)
  370.         {
  371.         "Sitting on "; obj.thedesc;" is "; listcont( obj );
  372.         ". ";
  373.         }
  374.         }
  375.         else if ( obj.contentsVisible and not obj.isqcontainer )
  376.         {
  377.             caps();
  378.             obj.thedesc; " seems to contain ";
  379.             listcont( obj );
  380.             ". ";
  381.         }
  382.     }
  383.     if ( obj.contentsVisible and not obj.isqcontainer )
  384.         listfixedcontcont( obj );
  385. }
  386.  
  387. /*
  388.  *  listfixedcontcont: function( obj )
  389.  *
  390.  *  List the contents of the contents of any fixeditem objects
  391.  *  in the contents list of the object obj.  This routine
  392.  *  makes sure that all objects that can be taken are listed somewhere
  393.  *  in a room's description.  This routine recurses down the contents
  394.  *  tree, following each branch until either something has been listed
  395.  *  or the branch ends without anything being listable.  This routine
  396.  *  displays a complete sentence, so no introductory or closing text
  397.  *  is needed.
  398.  */
  399. listfixedcontcont: function( obj )
  400. {
  401.     local list, i, tot, thisobj;
  402.  
  403.     list := obj.contents;
  404.     tot := length( list );
  405.     i := 1;
  406.     while ( i <= tot )
  407.     {
  408.         thisobj := list[i];
  409.         if ( thisobj.isfixed and thisobj.contentsVisible and
  410.       not thisobj.isqcontainer )
  411.             showcontcont( thisobj );
  412.     i := i + 1;
  413.     }
  414. }
  415.  
  416. /*
  417.  *  listcontcont: function( obj )
  418.  *
  419.  *  This function lists the contents of the contents of an object.
  420.  *  It displays full sentences, so no introductory or closing text
  421.  *  is required.  Any item in the contents list of the object
  422.  *  obj whose contentsVisible property is true has
  423.  *  its contents listed.  An Object whose isqcontainer or
  424.  *  isqsurface property is true will not have its
  425.  *  contents listed.
  426.  */
  427. listcontcont: function( obj )
  428. {
  429.     local list, i, tot;
  430.     list := obj.contents;
  431.     tot := length( list );
  432.     i := 1;
  433.     while ( i <= tot )
  434.     {
  435.         showcontcont( list[i] );
  436.     i := i + 1;
  437.     }
  438. }
  439.  
  440. /*
  441.  *  scoreStatus: function(points, turns)
  442.  *
  443.  *  This function updates the score on the status line.  This implementation
  444.  *  simply calls the built-in function setscore() with the same information.
  445.  *  The call to setscore() has been isolated in this function to make it
  446.  *  easier to replace with a customized version; to replace the status line
  447.  *  score display, simply replace this routine.
  448.  */
  449. scoreStatus: function(points, turns)
  450. {
  451.     setscore(points, turns);
  452. }
  453.  
  454. /*
  455.  *  turncount: function( parm )
  456.  *
  457.  *  This function can be used as a daemon (normally set up in the init
  458.  *  function) to update the turn counter after each turn.  This routine
  459.  *  increments global.turnsofar, and then calls setscore to
  460.  *  update the status line with the new turn count.
  461.  */
  462. turncount: function( parm )
  463. {
  464.     incturn();
  465.     global.turnsofar := global.turnsofar + 1;
  466.     scoreStatus( global.score, global.turnsofar );
  467. }
  468.  
  469. /*
  470.  *  addweight: function( list )
  471.  *
  472.  *  Adds the weights of the objects in list and returns the sum.
  473.  *  The weight of an object is given by its weight property.  This
  474.  *  routine includes the weights of all of the contents of each object,
  475.  *  and the weights of their contents, and so forth.
  476.  */
  477. addweight: function( l )
  478. {
  479.     local tot, i, c, totweight;
  480.  
  481.     tot := length( l );
  482.     i := 1;
  483.     totweight := 0;
  484.     while ( i <= tot )
  485.     {
  486.         c := l[i];
  487.         totweight := totweight + c.weight;
  488.         if (length( c.contents ))
  489.             totweight := totweight + addweight( c.contents );
  490.         i := i + 1;
  491.     }
  492.     return( totweight );
  493. }
  494.  
  495. /*
  496.  *  addbulk: function( list )
  497.  *
  498.  *  This function returns the sum of the bulks (given by the bulk
  499.  *  property) of each object in list.  The value returned includes
  500.  *  only the bulk of each object in the list, and not of the contents
  501.  *  of the objects, as it is assumed that an object does not change in
  502.  *  size when something is put inside it.  You can easily change this
  503.  *  assumption for special objects (such as a bag that stretches as
  504.  *  things are put inside) by writing an appropriate bulk method
  505.  *  for that object.
  506.  */
  507. addbulk: function( list )
  508. {
  509.     local i, tot, totbulk, rem, cur;
  510.  
  511.     tot := length( list );
  512.     i := 1;
  513.     totbulk := 0;
  514.     while( i <= tot )
  515.     {
  516.         cur := list[i];
  517.         if ( not cur.isworn )
  518.             totbulk := totbulk + cur.bulk;
  519.         i := i + 1;
  520.     }
  521.     return( totbulk );
  522. }
  523.  
  524. /*
  525.  *  incscore: function( amount )
  526.  *
  527.  *  Adds amount to the total score, and updates the status line
  528.  *  to reflect the new score.  The total score is kept in global.score.
  529.  *  Always use this routine rather than changing global.score
  530.  *  directly, since this routine ensures that the status line is
  531.  *  updated with the new value.
  532.  */
  533. incscore: function( amount )
  534. {
  535.     global.score := global.score + amount;
  536.     scoreStatus( global.score, global.turnsofar );
  537. }
  538.  
  539. /*
  540.  *  initSearch: function
  541.  *
  542.  *  Initializes the containers of objects with a searchLoc, underLoc,
  543.  *  and behindLoc by setting up searchCont, underCont, and
  544.  *  behindCont lists, respectively.  You should call this function once in
  545.  *  your preinit (or init, if you prefer) function to ensure that
  546.  *  the underable, behindable, and searchable objects are set up correctly.
  547.  *  
  548.  *  As a bonus, we take this opportunity to initialize global.floatingList
  549.  *  with a list of all objects of class floatingItem.  It is necessary to
  550.  *  initialize this list, so that validDoList and validIoList include objects
  551.  *  with variable location properties.  Note that, for this to work,
  552.  *  all objects with variable location properties must be declared
  553.  *  to be of class floatingItem.
  554.  */
  555. initSearch: function
  556. {
  557.     local o;
  558.     
  559.     o := firstobj(hiddenItem);
  560.     while (o <> nil)
  561.     {
  562.     if (o.searchLoc)
  563.         o.searchLoc.searchCont := o.searchLoc.searchCont + o;
  564.     else if (o.underLoc)
  565.         o.underLoc.underCont := o.underLoc.underCont + o;
  566.     else if (o.behindLoc)
  567.         o.behindLoc.behindCont := o.behindLoc.behindCont + o;
  568.     o := nextobj(o, hiddenItem);
  569.     }
  570.     
  571.     global.floatingList := [];
  572.     for (o := firstobj(floatingItem) ; o ; o := nextobj(o, floatingItem))
  573.     global.floatingList += o;
  574. }
  575.  
  576. /*
  577.  *  reachableList: function
  578.  *
  579.  *  Returns a list of all the objects reachable from a given object.
  580.  *  That is, if the object is open or is not an openable, it returns the
  581.  *  contents of the object, plus the reachableList result of each object;
  582.  *  if the object is closed, it returns an empty list.
  583.  */
  584. reachableList: function(obj)
  585. {
  586.     local ret := [];
  587.     local i, lst, len;
  588.     
  589.     if (not isclass(obj, openable)
  590.     or (isclass(obj, openable) and obj.isopen))
  591.     {
  592.     lst := obj.contents;
  593.     len := length(lst);
  594.     ret += lst;
  595.     for (i := 1 ; i <= len ; ++i)
  596.         ret += reachableList(lst[i]);
  597.     }
  598.  
  599.     return(ret);
  600. }
  601.  
  602. /*
  603.  *  visibleList: function
  604.  *
  605.  *  This function is similar to reachableList, but returns the
  606.  *  list of objects visible within a given object.
  607.  */
  608. visibleList: function(obj)
  609. {
  610.     local ret := [];
  611.     local i, lst, len;
  612.     
  613.     if (not isclass(obj, openable)
  614.     or (isclass(obj, openable) and obj.isopen)
  615.     or obj.contentsVisible)
  616.     {
  617.     lst := obj.contents;
  618.     len := length(lst);
  619.     ret += lst;
  620.     for (i := 1 ; i <= len ; ++i)
  621.         ret += visibleList(lst[i]);
  622.     }
  623.  
  624.     return(ret);
  625. }
  626.  
  627. /*
  628.  *  nestedroom: room
  629.  *
  630.  *  A special kind of room that is inside another room; chairs and
  631.  *  some types of vehicles, such as inflatable rafts, fall into this
  632.  *  category.  Note that a room can be within another room without
  633.  *  being a nestedroom, simply by setting its location property
  634.  *  to another room.  The nestedroom is different from an ordinary
  635.  *  room, though, in that it's an "open" room; that is, when inside it,
  636.  *  the actor is still really inside the enclosing room for purposes of
  637.  *  descriptions.  Hence, the player sees "Laboratory, in the chair."
  638.  *  In addition, a nestedroom is an object in its own right,
  639.  *  visible to the player; for example, a chair is an object in a
  640.  *  room in addition to being a room itself.  The statusPrep
  641.  *  property displays the preposition in the status description; by
  642.  *  default, it will be "in," but some subclasses and instances
  643.  *  will want to change this to a more appropriate preposition.
  644.  *  outOfPrep is used to report what happens when the player
  645.  *  gets out of the object:  it should be "out of" or "off of" as
  646.  *  appropriate to this object.
  647.  */
  648. class nestedroom: room
  649.     statusPrep = "in"
  650.     outOfPrep = "out of"
  651.     islit =
  652.     {
  653.         if ( self.location ) return( self.location.islit );
  654.         return( nil );
  655.     }
  656.     statusLine =
  657.     {
  658.     "<<self.location.sdesc>>, <<self.statusPrep>> <<self.thedesc>>\n\t";
  659.     }
  660.     lookAround( verbosity ) =
  661.     {
  662.         self.statusLine;
  663.     self.location.nrmLkAround( verbosity );
  664.     }
  665.     roomDrop( obj ) =
  666.     {
  667.         if ( self.location = nil or self.isdroploc ) pass roomDrop;
  668.     else self.location.roomDrop( obj );
  669.     }
  670. ;
  671.  
  672. /*
  673.  *  chairitem: fixeditem, nestedroom, surface
  674.  *
  675.  *  Acts like a chair:  actors can sit on the object.  While sitting
  676.  *  on the object, an actor can't go anywhere until standing up, and
  677.  *  can only reach objects that are on the chair and in the chair's
  678.  *  reachable list.  By default, nothing is in the reachable
  679.  *  list.  Note that there is no real distinction made between chairs
  680.  *  and beds, so you can sit or lie on either; the only difference is
  681.  *  the message displayed describing the situation.
  682.  */
  683. class chairitem: fixeditem, nestedroom, surface
  684.     reachable = ([] + self) // list of all containers reachable from here;
  685.                             //  normally, you can only reach carried items
  686.                             //  from a chair, but this makes special allowances
  687.     ischair = true          // it is a chair by default; for beds or other
  688.                             //  things you lie down on, make it false
  689.     outOfPrep = "out of"
  690.     roomAction( actor, v, dobj, prep, io ) =
  691.     {
  692.         if ( dobj<>nil and v<>inspectVerb )
  693.             checkReach( self, actor, v, dobj );
  694.         if ( io<>nil and v<>askVerb and v<>tellVerb )
  695.             checkReach( self, actor, v, io );
  696.     pass roomAction;
  697.     }
  698.     enterRoom( actor ) = {}
  699.     noexit =
  700.     {
  701.         "%You're% not going anywhere until %you%
  702.         get%s% <<outOfPrep>> <<thedesc>>. ";
  703.         return( nil );
  704.     }
  705.     verDoBoard( actor ) = { self.verDoSiton( actor ); }
  706.     doBoard( actor ) = { self.doSiton( actor ); }
  707.     verDoSiton( actor ) =
  708.     {
  709.         if ( actor.location = self )
  710.         {
  711.             "%You're% already on "; self.thedesc; "! ";
  712.         }
  713.     }
  714.     doSiton( actor ) =
  715.     {
  716.         "Okay, %you're% now sitting on "; self.thedesc; ". ";
  717.         actor.travelTo( self );
  718.     }
  719.     verDoLieon( actor ) =
  720.     {
  721.         self.verDoSiton( actor );
  722.     }
  723.     doLieon( actor ) =
  724.     {
  725.         self.doSiton( actor );
  726.     }
  727. ;
  728.  
  729. /*
  730.  *  beditem: chairitem
  731.  *
  732.  *  This object is the same as a chairitem, except that the player
  733.  *  is described as lying on, rather than sitting in, the object.
  734.  */
  735. class beditem: chairitem
  736.     ischair = nil
  737.     isbed = true
  738.     sdesc = "bed"
  739.     statusPrep = "on"
  740.     outOfPrep = "out of"
  741.     doLieon(actor) =
  742.     {
  743.         "Okay, %you're% now lying on <<self.thedesc>>.";
  744.     actor.travelTo(self);
  745.     }
  746. ;
  747.     
  748. /*
  749.  *  floatingItem: object
  750.  *
  751.  *  This class doesn't do anything apart from mark an object as having a
  752.  *  variable location property.  It is necessary to mark all such
  753.  *  items by making them a member of this class, so that the objects are
  754.  *  added to global.floatingList, which is necessary so that floating
  755.  *  objects are included in validDoList and validIoList values (see
  756.  *  the deepverb class for a description of these methods).
  757.  */
  758. class floatingItem: object
  759. ;
  760.  
  761. /*
  762.  *  thing: object
  763.  *
  764.  *  The basic class for objects in a game.  The property contents
  765.  *  is a list that specifies what is in the object; this property is
  766.  *  automatically set up by the system after the game is compiled to
  767.  *  contain a list of all objects that have this object as their
  768.  *  location property.  The contents property is kept
  769.  *  consistent with the location properties of referenced objects
  770.  *  by the moveInto method; always use moveInto rather than
  771.  *  directly setting a location property for this reason.  The
  772.  *  adesc method displays the name of the object with an indefinite
  773.  *  article; the default is to display "a" followed by the sdesc,
  774.  *  but objects that need a different indefinite article (such as "an"
  775.  *  or "some") should override this method.  Likewise, thedesc
  776.  *  displays the name with a definite article; by default, thedesc
  777.  *  displays "the" followed by the object's sdesc.  The sdesc
  778.  *  simply displays the object's name ("short description") without
  779.  *  any articles.  The ldesc is the long description, normally
  780.  *  displayed when the object is examined by the player; by default,
  781.  *  the ldesc displays "It looks like an ordinary sdesc."
  782.  *  The isIn(object) method returns true if the
  783.  *  object's location is the specified object or the object's
  784.  *  location is an object whose contentsVisible property is
  785.  *  true and that object's isIn(object) method is
  786.  *  true.  Note that if isIn is true, it doesn't
  787.  *  necessarily mean the object is reachable, because isIn is
  788.  *  true if the object is merely visible within the location.
  789.  *  The moveInto(object) method moves the object to be inside
  790.  *  the specified object.  To make an object disappear, move it
  791.  *  into nil.
  792.  */
  793. class thing: object
  794.     weight = 0
  795.     bulk = 1
  796.     isListed = true         // shows up in room/inventory listings
  797.     contents = []           // set up automatically by system - do not set
  798.     verGrab( obj ) = {}
  799.     Grab( obj ) = {}
  800.     adesc =
  801.     {
  802.         "a "; self.sdesc;   // default is "a <name>"; "self" is current object
  803.     }
  804.     pluraldesc =            // default is to add "s" to the sdesc
  805.     {
  806.     self.sdesc; "s";
  807.     }
  808.     thedesc =
  809.     {
  810.         "the "; self.sdesc; // default is "the <name>"
  811.     }
  812.     multisdesc = { self.sdesc; }
  813.     ldesc = { "It looks like an ordinary "; self.sdesc; " to %me%."; }
  814.     readdesc = { "%You% can't read "; self.adesc; ". "; }
  815.     actorAction( v, d, p, i ) =
  816.     {
  817.         "You have lost your mind. ";
  818.         exit;
  819.     }
  820.     contentsVisible = { return( true ); }
  821.     contentsReachable = { return( true ); }
  822.     isIn( obj ) =
  823.     {
  824.         local myloc;
  825.  
  826.         myloc := self.location;
  827.         if ( myloc )
  828.         {
  829.             if ( myloc = obj ) return( true );
  830.             if ( myloc.contentsVisible ) return( myloc.isIn( obj ));
  831.         }
  832.         return( nil );
  833.     }
  834.     moveInto( obj ) =
  835.     {
  836.         local loc;
  837.  
  838.     /*
  839.      *   For the object containing me, and its container, and so forth,
  840.      *   tell it via a Grab message that I'm going away.
  841.      */
  842.     loc := self.location;
  843.     while ( loc )
  844.     {
  845.         loc.Grab( self );
  846.         loc := loc.location;
  847.     }
  848.  
  849.         if ( self.location )
  850.             self.location.contents := self.location.contents - self;
  851.         self.location := obj;
  852.         if ( obj ) obj.contents := obj.contents + self;
  853.     }
  854.     verDoSave( actor ) =
  855.     {
  856.         "Please specify the name of the game to save in double quotes,
  857.         for example, SAVE \"GAME1\". ";
  858.     }
  859.     verDoRestore( actor ) =
  860.     {
  861.         "Please specify the name of the game to restore in double quotes,
  862.         for example, RESTORE \"GAME1\". ";
  863.     }
  864.     verDoScript( actor ) =
  865.     {
  866.         "You should type the name of a file to write the transcript to
  867.         in quotes, for example, SCRIPT \"LOG1\". ";
  868.     }
  869.     verDoSay( actor ) =
  870.     {
  871.         "You should say what you want to say in double quotes, for example,
  872.         SAY \"HELLO\". ";
  873.     }
  874.     verDoPush( actor ) =
  875.     {
  876.         "Pushing "; self.thedesc; " doesn't do anything. ";
  877.     }
  878.     verDoWear( actor ) =
  879.     {
  880.         "%You% can't wear "; self.thedesc; ". ";
  881.     }
  882.     verDoTake( actor ) =
  883.     {
  884.         if ( self.location = actor )
  885.         {
  886.             "%You% already %have% "; self.thedesc; "! ";
  887.         }
  888.         else self.verifyRemove( actor );
  889.     }
  890.     verifyRemove( actor ) =
  891.     {
  892.       /*
  893.      *   Check with each container to make sure that the container
  894.      *   doesn't object to the object's removal.
  895.      */
  896.         local loc;
  897.  
  898.         loc := self.location;
  899.         while ( loc )
  900.         {
  901.             if ( loc <> actor ) loc.verGrab( self );
  902.             loc := loc.location;
  903.         }
  904.     }
  905.     isVisible( vantage ) =
  906.     {
  907.         local loc;
  908.  
  909.         loc := self.location;
  910.         if ( loc = nil ) return( nil );
  911.  
  912.     /*
  913.      *   if the vantage is inside me, and my contents are visible,
  914.      *   I'm visible 
  915.      */
  916.     if (vantage.location = self and self.contentsVisible)
  917.         return true;
  918.  
  919.         /* if I'm in the vantage, I'm visible */
  920.         if ( loc = vantage ) return( true );
  921.  
  922.         /*
  923.          *   if its location's contents are visible, and its location is
  924.          *   itself visible, it's visible
  925.          */
  926.         if ( loc.contentsVisible and loc.isVisible( vantage )) return( true );
  927.  
  928.         /*
  929.          *   If the vantage has a location, and the vantage's location's
  930.          *   contents are visible (if you can see me I can see you), and
  931.          *   the object is visible from the vantage's location, the object
  932.          *   is visible
  933.          */
  934.         if ( vantage.location <> nil and vantage.location.contentsVisible and
  935.          self.isVisible( vantage.location ))
  936.             return( true );
  937.  
  938.         /* all tests failed:  it's not visible */
  939.         return( nil );
  940.     }
  941.     cantReach( actor ) =
  942.     {
  943.         if ( self.location = nil )
  944.         {
  945.             if ( actor.location.location )
  946.                "%You% can't reach that from << actor.location.thedesc >>. ";
  947.             return;
  948.         }
  949.         if ( not self.location.isopenable or self.location.isopen )
  950.             self.location.cantReach( actor );
  951.         else "%You%'ll have to open << self.location.thedesc >> first. ";
  952.     }
  953.     isReachable( actor ) =
  954.     {
  955.         local loc;
  956.  
  957.         /* if the object is in the room's 'reachable' list, it's reachable */
  958.         if (find( actor.location.reachable, self ) <> nil )
  959.             return( true );
  960.  
  961.         /*
  962.          *   If the object's container's contents are reachable, and the
  963.          *   container is reachable, the object is reachable.
  964.          */
  965.         loc := self.location;
  966.     if (find( actor.location.reachable, self ) <> nil )
  967.         return( true );
  968.     if ( loc = nil ) return( nil );
  969.     if ( loc = actor or loc = actor.location ) return( true );
  970.     if ( loc.contentsReachable )
  971.         return( loc.isReachable( actor ));
  972.     return( nil );
  973.         return( nil );
  974.     }
  975.     doTake( actor ) =
  976.     {
  977.         local totbulk, totweight;
  978.  
  979.         totbulk := addbulk( actor.contents ) + self.bulk;
  980.         totweight := addweight( actor.contents );
  981.         if ( not actor.isCarrying( self ))
  982.             totweight := totweight + self.weight + addweight(self.contents);
  983.  
  984.         if ( totweight > actor.maxweight )
  985.             "%Your% load is too heavy. ";
  986.         else if ( totbulk > actor.maxbulk )
  987.             "%You've% already got %your% hands full. ";
  988.         else
  989.         {
  990.             self.moveInto( actor );
  991.             "Taken. ";
  992.         }
  993.     }
  994.     verDoDrop( actor ) =
  995.     {
  996.         if ( not actor.isCarrying( self ))
  997.         {
  998.             "%You're% not carrying "; self.thedesc; "! ";
  999.         }
  1000.         else self.verifyRemove( actor );
  1001.     }
  1002.     doDrop( actor ) =
  1003.     {
  1004.         actor.location.roomDrop( self );
  1005.     }
  1006.     verDoUnwear( actor ) =
  1007.     {
  1008.         "%You're% not wearing "; self.thedesc; "! ";
  1009.     }
  1010.     verIoPutIn( actor ) =
  1011.     {
  1012.         "%You% can't put anything into "; self.thedesc; ". ";
  1013.     }
  1014.     circularMessage(io) =
  1015.     {
  1016.         local cont;
  1017.  
  1018.     "%You% can't put <<thedesc>> in <<io.thedesc>>, because
  1019.     <<io.thedesc>> is <<io.location = self ? "already" : ""
  1020.         >> <<io.location.issurface ? "on" : "in">> <<io.location.thedesc>>";
  1021.     for (cont := io.location ; cont <> self ; cont := cont.location)
  1022.     {
  1023.         ", which is ";
  1024.             if (cont.location = self) "already ";
  1025.             "<<cont.location.issurface ? "on" : "in"
  1026.             >> <<cont.location.thedesc>>";
  1027.     }
  1028.     ".";
  1029.     }
  1030.     verDoPutIn( actor, io ) =
  1031.     {
  1032.         if ( io = nil ) return;
  1033.  
  1034.         if ( self.location = io )
  1035.         {
  1036.             caps(); self.thedesc; " is already in "; io.thedesc; "! ";
  1037.         }
  1038.         else if (io = self)
  1039.         {
  1040.             "%You% can't put "; self.thedesc; " in itself! ";
  1041.         }
  1042.         else if (io.isIn(self))
  1043.         self.circularMessage(io);
  1044.         else
  1045.             self.verifyRemove( actor );
  1046.     }
  1047.     doPutIn( actor, io ) =
  1048.     {
  1049.         self.moveInto( io );
  1050.         "Done. ";
  1051.     }
  1052.     verIoPutOn( actor ) =
  1053.     {
  1054.         "There's no good surface on "; self.thedesc; ". ";
  1055.     }
  1056.     verDoPutOn( actor, io ) =
  1057.     {
  1058.         if ( io = nil ) return;
  1059.  
  1060.         if ( self.location = io )
  1061.         {
  1062.             caps(); self.thedesc; " is already on "; io.thedesc; "! ";
  1063.         }
  1064.     else if (io = self)
  1065.         {
  1066.             "%You% can't put "; self.thedesc; " on itself! ";
  1067.         }
  1068.     else if (io.isIn(self))
  1069.         self.circularMessage(io);
  1070.         else
  1071.         self.verifyRemove( actor );
  1072.     }
  1073.     doPutOn( actor, io ) =
  1074.     {
  1075.         self.moveInto( io );
  1076.         "Done. ";
  1077.     }
  1078.     verIoTakeOut( actor ) = {}
  1079.     ioTakeOut( actor, dobj ) =
  1080.     {
  1081.         dobj.doTakeOut( actor, self );
  1082.     }
  1083.     verDoTakeOut( actor, io ) =
  1084.     {
  1085.         if ( io <> nil and not self.isIn( io ))
  1086.         {
  1087.             caps(); self.thedesc; " isn't in "; io.thedesc; ". ";
  1088.         }
  1089.     self.verDoTake(actor);         /* ensure object can be taken at all */
  1090.     }
  1091.     doTakeOut( actor, io ) =
  1092.     {
  1093.         self.doTake( actor );
  1094.     }
  1095.     verIoTakeOff( actor ) = {}
  1096.     ioTakeOff( actor, dobj ) =
  1097.     {
  1098.         dobj.doTakeOff( actor, self );
  1099.     }
  1100.     verDoTakeOff( actor, io ) =
  1101.     {
  1102.         if ( io <> nil and not self.isIn( io ))
  1103.         {
  1104.             caps(); self.thedesc; " isn't on "; io.thedesc; "! ";
  1105.         }
  1106.     self.verDoTake(actor);         /* ensure object can be taken at all */
  1107.     }
  1108.     doTakeOff( actor, io ) =
  1109.     {
  1110.         self.doTake( actor );
  1111.     }
  1112.     verIoPlugIn( actor ) =
  1113.     {
  1114.         "%You% can't plug anything into "; self.thedesc; ". ";
  1115.     }
  1116.     verDoPlugIn( actor, io ) =
  1117.     {
  1118.         "%You% can't plug "; self.thedesc; " into anything. ";
  1119.     }
  1120.     verIoUnplugFrom( actor ) =
  1121.     {
  1122.         "It's not plugged into "; self.thedesc; ". ";
  1123.     }
  1124.     verDoUnplugFrom( actor, io ) =
  1125.     {
  1126.         if ( io <> nil ) { "It's not plugged into "; io.thedesc; ". "; }
  1127.     }
  1128.     verDoLookin( actor ) =
  1129.     {
  1130.         "There's nothing in "; self.thedesc; ". ";
  1131.     }
  1132.     thrudesc = { "%You% can't see much through << thedesc >>.\n"; }
  1133.     verDoLookthru( actor ) =
  1134.     {
  1135.         "%You% can't see anything through "; self.thedesc; ". ";
  1136.     }
  1137.     verDoLookunder( actor ) =
  1138.     {
  1139.         "There's nothing under "; self.thedesc; ". ";
  1140.     }
  1141.     verDoInspect( actor ) = {}
  1142.     doInspect( actor ) =
  1143.     {
  1144.         self.ldesc;
  1145.     }
  1146.     verDoRead( actor ) =
  1147.     {
  1148.         "I don't know how to read "; self.thedesc; ". ";
  1149.     }
  1150.     verDoLookbehind( actor ) =
  1151.     {
  1152.         "There's nothing behind "; self.thedesc; ". ";
  1153.     }
  1154.     verDoTurn( actor ) =
  1155.     {
  1156.         "Turning "; self.thedesc; " doesn't have any effect. ";
  1157.     }
  1158.     verDoTurnWith( actor, io ) =
  1159.     {
  1160.         "Turning "; self.thedesc; " doesn't have any effect. ";
  1161.     }
  1162.     verDoTurnTo( actor, io ) =
  1163.     {
  1164.         "Turning "; self.thedesc; " doesn't have any effect. ";
  1165.     }
  1166.     verIoTurnTo( actor ) =
  1167.     {
  1168.         "I don't know how to do that. ";
  1169.     }
  1170.     verDoTurnon( actor ) =
  1171.     {
  1172.         "I don't know how to turn "; self.thedesc; " on. ";
  1173.     }
  1174.     verDoTurnoff( actor ) =
  1175.     {
  1176.         "I don't know how to turn "; self.thedesc; " off. ";
  1177.     }
  1178.     verIoAskAbout( actor ) = {}
  1179.     ioAskAbout( actor, dobj ) =
  1180.     {
  1181.         dobj.doAskAbout( actor, self );
  1182.     }
  1183.     verDoAskAbout( actor, io ) =
  1184.     {
  1185.         "Surely, %you% can't think "; self.thedesc; " knows anything
  1186.         about it! ";
  1187.     }
  1188.     verIoTellAbout( actor ) = {}
  1189.     ioTellAbout( actor, dobj ) =
  1190.     {
  1191.         dobj.doTellAbout( actor, self );
  1192.     }
  1193.     verDoTellAbout( actor, io ) =
  1194.     {
  1195.         "It doesn't look as though "; self.thedesc; " is interested. ";
  1196.     }
  1197.     verDoUnboard( actor ) =
  1198.     {
  1199.         if ( actor.location <> self )
  1200.         {
  1201.             "%You're% not in "; self.thedesc; "! ";
  1202.         }
  1203.         else if ( self.location=nil )
  1204.         {
  1205.             "%You% can't get out of "; self.thedesc; "! ";
  1206.         }
  1207.     }
  1208.     doUnboard( actor ) =
  1209.     {
  1210.         if ( self.fastenitem )
  1211.     {
  1212.         "%You%'ll have to unfasten "; actor.location.fastenitem.thedesc;
  1213.         " first. ";
  1214.     }
  1215.     else
  1216.     {
  1217.             "Okay, %you're% no longer in "; self.thedesc; ". ";
  1218.             self.leaveRoom( actor );
  1219.         actor.moveInto( self.location );
  1220.     }
  1221.     }
  1222.     verDoAttackWith( actor, io ) =
  1223.     {
  1224.         "Attacking "; self.thedesc; " doesn't appear productive. ";
  1225.     }
  1226.     verIoAttackWith( actor ) =
  1227.     {
  1228.         "It's not very effective to attack with "; self.thedesc; ". ";
  1229.     }
  1230.     verDoEat( actor ) =
  1231.     {
  1232.         caps(); self.thedesc; " doesn't appear appetizing. ";
  1233.     }
  1234.     verDoDrink( actor ) =
  1235.     {
  1236.         caps(); self.thedesc; " doesn't appear appetizing. ";
  1237.     }
  1238.     verDoGiveTo( actor, io ) =
  1239.     {
  1240.         if ( not actor.isCarrying( self ))
  1241.         {
  1242.             "%You're% not carrying "; self.thedesc; ". ";
  1243.         }
  1244.         else self.verifyRemove( actor );
  1245.     }
  1246.     doGiveTo( actor, io ) =
  1247.     {
  1248.         self.moveInto( io );
  1249.         "Done. ";
  1250.     }
  1251.     verDoPull( actor ) =
  1252.     {
  1253.         "Pulling "; self.thedesc; " doesn't have any effect. ";
  1254.     }
  1255.     verDoThrowAt( actor, io ) =
  1256.     {
  1257.         if ( not actor.isCarrying( self ))
  1258.         {
  1259.             "%You're% not carrying "; self.thedesc; ". ";
  1260.         }
  1261.         else self.verifyRemove( actor );
  1262.     }
  1263.     doThrowAt( actor, io ) =
  1264.     {
  1265.         "%You% miss%es%. ";
  1266.         self.moveInto( actor.location );
  1267.     }
  1268.     verIoThrowAt( actor ) =
  1269.     {
  1270.         if ( actor.isCarrying( self ))
  1271.         {
  1272.             "%You% could at least drop "; self.thedesc; " first. ";
  1273.         }
  1274.     }
  1275.     ioThrowAt( actor, dobj ) =
  1276.     {
  1277.         dobj.doThrowAt( actor, self );
  1278.     }
  1279.     verDoThrowTo( actor, io ) =
  1280.     {
  1281.         if ( not actor.isCarrying( self ))
  1282.         {
  1283.             "%You're% not carrying "; self.thedesc; ". ";
  1284.         }
  1285.         else self.verifyRemove( actor );
  1286.     }
  1287.     doThrowTo( actor, io ) =
  1288.     {
  1289.         "%You% miss%es%. ";
  1290.         self.moveInto( actor.location );
  1291.     }
  1292.     verDoThrow( actor ) =
  1293.     {
  1294.         if ( not actor.isCarrying( self ))
  1295.         {
  1296.             "%You're% not carrying "; self.thedesc; ". ";
  1297.         }
  1298.         else self.verifyRemove( actor );
  1299.     }
  1300.     doThrow( actor ) =
  1301.     {
  1302.         "Thrown. ";
  1303.         self.moveInto( actor.location );
  1304.     }
  1305.     verDoShowTo( actor, io ) =
  1306.     {
  1307.     }
  1308.     doShowTo( actor, io ) =
  1309.     {
  1310.         if ( io <> nil ) { caps(); io.thedesc; " isn't impressed. "; }
  1311.     }
  1312.     verIoShowTo( actor ) =
  1313.     {
  1314.         caps(); self.thedesc; " isn't impressed. ";
  1315.     }
  1316.     verDoClean( actor ) =
  1317.     {
  1318.         caps(); self.thedesc; " looks a bit cleaner now. ";
  1319.     }
  1320.     verDoCleanWith( actor, io ) = {}
  1321.     doCleanWith( actor, io ) =
  1322.     {
  1323.         caps(); self.thedesc; " looks a bit cleaner now. ";
  1324.     }
  1325.     verDoMove( actor ) =
  1326.     {
  1327.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1328.     }
  1329.     verDoMoveTo( actor, io ) =
  1330.     {
  1331.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1332.     }
  1333.     verIoMoveTo( actor ) =
  1334.     {
  1335.         "That doesn't get us anywhere. ";
  1336.     }
  1337.     verDoMoveWith( actor, io ) =
  1338.     {
  1339.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1340.     }
  1341.     verIoMoveWith( actor ) =
  1342.     {
  1343.         caps(); self.thedesc; " doesn't seem to help. ";
  1344.     }
  1345.     verDoTypeOn( actor, io ) =
  1346.     {
  1347.         "You should say what you want to type in double quotes, for
  1348.         example, TYPE \"HELLO\" ON KEYBOARD. ";
  1349.     }
  1350.     verDoTouch( actor ) =
  1351.     {
  1352.         "Touching "; self.thedesc; " doesn't seem to have any effect. ";
  1353.     }
  1354.     verDoPoke( actor ) =
  1355.     {
  1356.         "Poking "; self.thedesc; " doesn't seem to have any effect. ";
  1357.     }
  1358.     verDoBreak(actor) = {}
  1359.     doBreak(actor) =
  1360.     {
  1361.     "You'll have to tell me how to do that.";
  1362.     }
  1363.     genMoveDir = { "%You% can't seem to do that. "; }
  1364.     verDoMoveN( actor ) = { self.genMoveDir; }
  1365.     verDoMoveS( actor ) = { self.genMoveDir; }
  1366.     verDoMoveE( actor ) = { self.genMoveDir; }
  1367.     verDoMoveW( actor ) = { self.genMoveDir; }
  1368.     verDoMoveNE( actor ) = { self.genMoveDir; }
  1369.     verDoMoveNW( actor ) = { self.genMoveDir; }
  1370.     verDoMoveSE( actor ) = { self.genMoveDir; }
  1371.     verDoMoveSW( actor ) = { self.genMoveDir; }
  1372.     verDoSearch( actor ) =
  1373.     {
  1374.         "%You% find%s% nothing of interest. ";
  1375.     }
  1376.  
  1377.     /* on dynamic construction, move into my contents list */
  1378.     construct =
  1379.     {
  1380.     self.moveInto(location);
  1381.     }
  1382.  
  1383.     /* on dynamic destruction, move out of contents list */
  1384.     destruct =
  1385.     {
  1386.     self.moveInto(nil);
  1387.     }
  1388.  
  1389.     /*
  1390.      *   Make it so that the player can give a command to an actor only
  1391.      *   if an actor is reachable in the normal manner.  This method
  1392.      *   returns true when 'self' can be given a command by the player. 
  1393.      */
  1394.     validActor = (self.isReachable(Me))
  1395. ;
  1396.  
  1397. /*
  1398.  *  item: thing
  1399.  *
  1400.  *  A basic item which can be picked up by the player.  It has no weight
  1401.  *  (0) and minimal bulk (1).  The weight property should be set
  1402.  *  to a non-zero value for heavy objects.  The bulk property
  1403.  *  should be set to a value greater than 1 for bulky objects, and to
  1404.  *  zero for objects that are very small and take essentially no effort
  1405.  *  to hold---or, more precisely, don't detract at all from the player's
  1406.  *  ability to hold other objects (for example, a piece of paper).
  1407.  */
  1408. class item: thing
  1409.     weight = 0
  1410.     bulk = 1
  1411. ;
  1412.     
  1413. /*
  1414.  *  lightsource: item
  1415.  *
  1416.  *  A portable lamp, candle, match, or other source of light.  The
  1417.  *  light source can be turned on and off with the islit property.
  1418.  *  If islit is true, the object provides light, otherwise it's
  1419.  *  just an ordinary object.  Note that this object provides a doTurnon
  1420.  *  method to provide appropriate behavior for a switchable light source,
  1421.  *  such as a flashlight or a room's electric lights.  However, this object
  1422.  *  does not provide a verDoTurnon method, so by default it can't be
  1423.  *  switched on and off.  To create something like a flashlight that should
  1424.  *  be a lightsource that can be switched on and off, simply include both
  1425.  *  lightsource and switchItem in the superclass list, and be sure
  1426.  *  that lightsource precedes switchItem in the superclass list,
  1427.  *  because the doTurnon method provided by lightsource should
  1428.  *  override the one provided by switchItem.  The doTurnon method
  1429.  *  provided here turns on the light source (by setting its isActive
  1430.  *  property to true, and then describes the room if it was previously
  1431.  *  dark.
  1432.  */
  1433. class lightsource: item
  1434.     islamp = true
  1435.     doTurnon(actor) =
  1436.     {
  1437.     local waslit := actor.location.islit;
  1438.  
  1439.     // turn on the light
  1440.     self.isActive := true;
  1441.     "You switch on <<thedesc>>";
  1442.  
  1443.     // if the room wasn't previously lit, and it is now, describe it
  1444.     if (actor.location.islit and not waslit)
  1445.     {
  1446.         ", lighting the area.\b";
  1447.         actor.location.enterRoom(actor);
  1448.     }
  1449.     else
  1450.         ".";
  1451.     }
  1452. ;
  1453.  
  1454. /*
  1455.  *  hiddenItem: object
  1456.  *
  1457.  *  This is an object that is hidden with one of the hider classes. 
  1458.  *  A hiddenItem object doesn't have any special properties in its
  1459.  *  own right, but all objects hidden with one of the hider classes
  1460.  *  must be of class hiddenItem so that initSearch can find
  1461.  *  them.
  1462.  */
  1463. class hiddenItem: object
  1464. ;
  1465.  
  1466. /*
  1467.  *  hider: item
  1468.  *
  1469.  *  This is a basic class of object that can hide other objects in various
  1470.  *  ways.  The underHider, behindHider, and searchHider classes
  1471.  *  are examples of hider subclasses.  The class defines
  1472.  *  the method searchObj(actor, list), which is given the list
  1473.  *  of hidden items contained in the object (for example, this would be the
  1474.  *  underCont property, in the case of an underHider), and "finds"
  1475.  *  the object or objects. Its action is dependent upon a couple of other
  1476.  *  properties of the hider object.  The serialSearch property,
  1477.  *  if true, indicates that items in the list are to be found one at
  1478.  *  a time; if nil (the default), the entire list is found on the
  1479.  *  first try.  The autoTake property, if true, indicates that
  1480.  *  the actor automatically takes the item or items found; if nil, the
  1481.  *  item or items are moved to the actor's location.  The searchObj method
  1482.  *  returns the list with the found object or objects removed; the
  1483.  *  caller should assign this returned value back to the appropriate
  1484.  *  property (for example, underHider will assign the return value
  1485.  *  to underCont).
  1486.  *  
  1487.  *  Note that because the hider is hiding something, this class
  1488.  *  overrides the normal verDoSearch method to display the
  1489.  *  message, "You'll have to be more specific about how you want
  1490.  *  to search that."  The reason is that the normal verDoSearch
  1491.  *  message ("You find nothing of interest") leads players to believe
  1492.  *  that the object was exhaustively searched, and we want to avoid
  1493.  *  misleading the player.  On the other hand, we don't want a general
  1494.  *  search to be exhaustive for most hider objects.  So, we just
  1495.  *  display a message letting the player know that the search was not
  1496.  *  enough, but we don't give away what they have to do instead.
  1497.  *  
  1498.  *  The objects hidden with one of the hider classes must be
  1499.  *  of class hiddenItem.
  1500.  */
  1501. class hider: item
  1502.     verDoSearch(actor) =
  1503.     {
  1504.     "%You%'ll have to be more specific about how %you% want%s%
  1505.     to search that. ";
  1506.     }
  1507.     searchObj(actor, list) =
  1508.     {
  1509.     local found, dest, i, tot;
  1510.  
  1511.     /* see how much we get this time */
  1512.     if (self.serialSearch)
  1513.     {
  1514.         found := [] + car(list);
  1515.         list := cdr(list);
  1516.     }
  1517.     else
  1518.     {
  1519.         found := list;
  1520.         list := nil;
  1521.     }
  1522.  
  1523.     /* set it(them) to the found item(s) */
  1524.         if (length(found) = 1)
  1525.         setit(found[1]);    // only one item - set 'it'
  1526.     else
  1527.         setit(found);       // multiple items - set 'them'
  1528.  
  1529.     /* figure destination */
  1530.     dest := actor;
  1531.     if (not self.autoTake) dest := dest.location;
  1532.     
  1533.     /* note what we found, and move it to destination */
  1534.     "%You% find%s% ";
  1535.     tot := length(found);
  1536.     i := 1;
  1537.     while (i <= tot)
  1538.     {
  1539.         found[i].adesc;
  1540.         if (i+1 < tot) ", ";
  1541.         else if (i = 1 and tot = 2) " and ";
  1542.         else if (i+1 = tot and tot > 2) ", and ";
  1543.         
  1544.         found[i].moveInto(dest);
  1545.         i := i + 1;
  1546.     }
  1547.  
  1548.     /* say what happened */
  1549.     if (self.autoTake) ", which %you% take%s%. ";
  1550.     else "! ";
  1551.  
  1552.     if (list<>nil and length(list)=0) list := nil;
  1553.     return(list);
  1554.     }
  1555.     serialSearch = nil             /* find everything in one try by default */
  1556.     autoTake = true               /* actor takes item when found by default */
  1557. ;
  1558.  
  1559. /*
  1560.  *  underHider: hider
  1561.  *
  1562.  *  This is an object that can have other objects placed under it.  The
  1563.  *  objects placed under it can only be found by looking under the object;
  1564.  *  see the description of hider for more information.  You should
  1565.  *  set the underLoc property of each hidden object to point to
  1566.  *  the underHider.
  1567.  *  
  1568.  *  Note that an underHider doesn't allow the player to put anything
  1569.  *  under the object during the game.  Instead, it's to make it easy for the
  1570.  *  game writer to set up hidden objects while implementing the game.  All you
  1571.  *  need to do to place an object under another object is declare the top
  1572.  *  object as an underHider, then declare the hidden object normally,
  1573.  *  except use underLoc rather than location to specify the
  1574.  *  location of the hidden object.  The behindHider and searchHider
  1575.  *  objects work similarly.
  1576.  *  
  1577.  *  The objects hidden with underHider must be of class hiddenItem.
  1578.  */
  1579. class underHider: hider
  1580.     underCont = []         /* list of items under me (set up by initSearch) */
  1581.     verDoLookunder(actor) = {}
  1582.     doLookunder(actor) =
  1583.     {
  1584.     if (self.underCont = nil)
  1585.         "There's nothing else under <<self.thedesc>>. ";
  1586.     else
  1587.         self.underCont := self.searchObj(actor, self.underCont);
  1588.     }
  1589. ;
  1590.  
  1591. /*
  1592.  *  behindHider: hider
  1593.  *
  1594.  *  This is just like an underHider, except that objects are hidden
  1595.  *  behind this object.  Objects to be behind this object should have their
  1596.  *  behindLoc property set to point to this object.
  1597.  *  
  1598.  *  The objects hidden with behindHider must be of class hiddenItem.
  1599.  */
  1600. class behindHider: hider
  1601.     behindCont = []
  1602.     verDoLookbehind(actor) = {}
  1603.     doLookbehind(actor) =
  1604.     {
  1605.     if (self.behindCont = nil)
  1606.         "There's nothing else behind <<self.thedesc>>. ";
  1607.     else
  1608.         self.behindCont := self.searchObj(actor, self.behindCont);
  1609.     }
  1610. ;
  1611.     
  1612. /*
  1613.  *  searchHider: hider
  1614.  *
  1615.  *  This is just like an underHider, except that objects are hidden
  1616.  *  within this object in such a way that the object must be looked in
  1617.  *  or searched.  Objects to be hidden in this object should have their
  1618.  *  searchLoc property set to point to this object.  Note that this
  1619.  *  is different from a normal container, in that the objects hidden within
  1620.  *  this object will not show up until the object is explicitly looked in
  1621.  *  or searched.
  1622.  *  
  1623.  *  The items hidden with searchHider must be of class hiddenItem.
  1624.  */
  1625. class searchHider: hider
  1626.     searchCont = []
  1627.     verDoSearch(actor) = {}
  1628.     doSearch(actor) =
  1629.     {
  1630.     if (self.searchCont = nil)
  1631.         "There's nothing else in <<self.thedesc>>. ";
  1632.     else
  1633.         self.searchCont := self.searchObj(actor, self.searchCont);
  1634.     }
  1635.     verDoLookin(actor) =
  1636.     {
  1637.     if (self.searchCont = nil)
  1638.         pass verDoLookin;
  1639.     }
  1640.     doLookin(actor) =
  1641.     {
  1642.     if (self.searchCont = nil)
  1643.         pass doLookin;
  1644.     else
  1645.         self.searchCont := self.searchObj(actor, self.searchCont);
  1646.     }
  1647. ;
  1648.     
  1649.  
  1650. /*
  1651.  *  fixeditem: thing
  1652.  *
  1653.  *  An object that cannot be taken or otherwise moved from its location.
  1654.  *  Note that a fixeditem is sometimes part of a movable object;
  1655.  *  this can be done to make one object part of another, ensuring that
  1656.  *  they cannot be separated.  By default, the functions that list a room's
  1657.  *  contents do not automatically describe fixeditem objects (because
  1658.  *  the isListed property is set to nil).  Instead, the game author
  1659.  *  will generally describe the fixeditem objects separately as part of
  1660.  *  the room's ldesc.  
  1661.  */
  1662. class fixeditem: thing      // An immovable object
  1663.     isListed = nil          // not listed in room/inventory displays
  1664.     isfixed = true          // Item can't be taken
  1665.     weight = 0              // no actual weight
  1666.     bulk = 0
  1667.     verDoTake( actor ) =
  1668.     {
  1669.         "%You% can't have "; self.thedesc; ". ";
  1670.     }
  1671.     verDoTakeOut( actor, io ) =
  1672.     {
  1673.         self.verDoTake( actor );
  1674.     }
  1675.     verDoDrop( actor ) =
  1676.     {
  1677.         "%You% can't drop "; self.thedesc; ". ";
  1678.     }
  1679.     verDoTakeOff( actor, io ) =
  1680.     {
  1681.         self.verDoTake( actor );
  1682.     }
  1683.     verDoPutIn( actor, io ) =
  1684.     {
  1685.         "%You% can't put "; self.thedesc; " anywhere. ";
  1686.     }
  1687.     verDoPutOn( actor, io ) =
  1688.     {
  1689.         "%You% can't put "; self.thedesc; " anywhere. ";
  1690.     }
  1691.     verDoMove( actor ) =
  1692.     {
  1693.         "%You% can't move "; self.thedesc; ". ";
  1694.     }
  1695.     verDoThrowAt(actor, iobj) =
  1696.     {
  1697.         "%You% can't throw <<self.thedesc>>.";
  1698.     }
  1699. ;
  1700.  
  1701. /*
  1702.  *  readable: item
  1703.  *
  1704.  *  An item that can be read.  The readdesc property is displayed
  1705.  *  when the item is read.  By default, the readdesc is the same
  1706.  *  as the ldesc, but the readdesc can be overridden to give
  1707.  *  a different message.
  1708.  */
  1709. class readable: item
  1710.     verDoRead( actor ) =
  1711.     {
  1712.     }
  1713.     doRead( actor ) =
  1714.     {
  1715.         self.readdesc;
  1716.     }
  1717.     readdesc =
  1718.     {
  1719.         self.ldesc;
  1720.     }
  1721. ;
  1722.  
  1723. /*
  1724.  *  fooditem: item
  1725.  *
  1726.  *  An object that can be eaten.  When eaten, the object is removed from
  1727.  *  the game, and global.lastMealTime is decremented by the
  1728.  *  foodvalue property.  By default, the foodvalue property
  1729.  *  is global.eatTime, which is the time between meals.  So, the
  1730.  *  default fooditem will last for one "nourishment interval."
  1731.  */
  1732. class fooditem: item
  1733.     verDoEat( actor ) =
  1734.     {
  1735.         self.verifyRemove( actor );
  1736.     }
  1737.     doEat( actor ) =
  1738.     {
  1739.         "That was delicious! ";
  1740.         global.lastMealTime := global.lastMealTime - self.foodvalue;
  1741.         self.moveInto( nil );
  1742.     }
  1743.     foodvalue = { return( global.eatTime ); }
  1744. ;
  1745.  
  1746. /*
  1747.  *  dialItem: fixeditem
  1748.  *
  1749.  *  This class is used for making "dials," which are controls in
  1750.  *  your game that can be turned to a range of numbers.  You must
  1751.  *  define the property maxsetting as a number specifying the
  1752.  *  highest number to which the dial can be turned; the lowest number
  1753.  *  on the dial is always 1.  The setting property is the dial's
  1754.  *  current setting, and can be changed by the player by typing the
  1755.  *  command "turn dial to number."  By default, the ldesc
  1756.  *  method displays the current setting.
  1757.  */
  1758. class dialItem: fixeditem
  1759.     maxsetting = 10 // it has settings from 1 to this number
  1760.     setting = 1     // the current setting
  1761.     ldesc =
  1762.     {
  1763.         caps(); self.thedesc; " can be turned to settings
  1764.         numbered from 1 to << self.maxsetting >>. It's
  1765.         currently set to << self.setting >>. ";
  1766.     }
  1767.     verDoTurn( actor ) = {}
  1768.     doTurn( actor ) =
  1769.     {
  1770.         askio( toPrep );
  1771.     }
  1772.     verDoTurnTo( actor, io ) = {}
  1773.     doTurnTo( actor, io ) =
  1774.     {
  1775.         if ( io = numObj )
  1776.         {
  1777.             if ( numObj.value < 1 or numObj.value > self.maxsetting )
  1778.             {
  1779.                 "There's no such setting! ";
  1780.             }
  1781.             else if ( numObj.value <> self.setting )
  1782.             {
  1783.                 self.setting := numObj.value;
  1784.                 "Okay, it's now turned to "; say( self.setting ); ". ";
  1785.             }
  1786.             else
  1787.             {
  1788.                 "It's already set to "; say( self.setting ); "! ";
  1789.             }
  1790.         }
  1791.         else
  1792.         {
  1793.             "I don't know how to turn "; self.thedesc;
  1794.             " to that. ";
  1795.         }
  1796.     }
  1797. ;
  1798.  
  1799. /*
  1800.  *  switchItem: fixeditem
  1801.  *
  1802.  *  This is a class for things that can be turned on and off by the
  1803.  *  player.  The only special property is isActive, which is nil
  1804.  *  if the switch is turned off and true when turned on.  The object
  1805.  *  accepts the commands "turn it on" and "turn it off,'' as well as
  1806.  *  synonymous constructions, and updates isActive accordingly.
  1807.  */
  1808. class switchItem: fixeditem
  1809.     verDoSwitch( actor ) = {}
  1810.     doSwitch( actor ) =
  1811.     {
  1812.         self.isActive := not self.isActive;
  1813.         "Okay, "; self.thedesc; " is now switched ";
  1814.         if ( self.isActive ) "on"; else "off";
  1815.         ". ";
  1816.     }
  1817.     verDoTurnon( actor ) =
  1818.     {
  1819.         /*
  1820.            You can't turn on something in the dark unless you're carrying
  1821.            it.  You also can't turn something on if it's already on.
  1822.         */
  1823.     if (not actor.location.islit and not actor.isCarrying(self))
  1824.         "It's pitch black.";
  1825.         else if ( self.isActive )
  1826.             "It's already turned on! ";
  1827.     }
  1828.     doTurnon( actor ) =
  1829.     {
  1830.         self.isActive := true;
  1831.         "Okay, it's now turned on. ";
  1832.     }
  1833.     verDoTurnoff( actor ) =
  1834.     {
  1835.         if ( not self.isActive ) "It's already turned off! ";
  1836.     }
  1837.     doTurnoff( actor ) =
  1838.     {
  1839.         self.isActive := nil;
  1840.         "Okay, it's now turned off. ";
  1841.     }
  1842. ;
  1843.  
  1844. /*
  1845.  *  room: thing
  1846.  *
  1847.  *  A location in the game.  By default, the islit property is
  1848.  *  true, which means that the room is lit (no light source is
  1849.  *  needed while in the room).  You should create a darkroom
  1850.  *  object rather than a room with islit set to nil if you
  1851.  *  want a dark room, because other methods are affected as well.
  1852.  *  The isseen property records whether the player has entered
  1853.  *  the room before; initially it's nil, and is set to true
  1854.  *  the first time the player enters.  The roomAction(actor,
  1855.  *  verb, directObject, preposition, indirectObject) method is
  1856.  *  activated for each player command; by default, all it does is
  1857.  *  call the room's location's roomAction method if the room
  1858.  *  is inside another room.  The lookAround(verbosity)
  1859.  *  method displays the room's description for a given verbosity
  1860.  *  level; true means a full description, nil means only
  1861.  *  the short description (just the room name plus a list of the
  1862.  *  objects present).  roomDrop(object) is called when
  1863.  *  an object is dropped within the room; normally, it just moves
  1864.  *  the object to the room and displays "Dropped."  The firstseen
  1865.  *  method is called when isseen is about to be set true
  1866.  *  for the first time (i.e., when the player first sees the room);
  1867.  *  by default, this routine does nothing, but it's a convenient
  1868.  *  place to put any special code you want to execute when a room
  1869.  *  is first entered.  The firstseen method is called after
  1870.  *  the room's description is displayed.
  1871.  */
  1872. class room: thing
  1873.     /*
  1874.      *   'reachable' is the list of explicitly reachable objects, over and
  1875.      *   above the objects that are here.  This is mostly used in nested
  1876.      *   rooms to make objects in the containing room accessible.  Most
  1877.      *   normal rooms will leave this as an empty list.
  1878.      */
  1879.     reachable = []
  1880.     
  1881.     /*
  1882.      *   roomCheck is true if the verb is valid in the room.  This
  1883.      *   is a first pass; generally, its only function is to disallow
  1884.      *   certain commands in a dark room.
  1885.      */
  1886.     roomCheck( v ) = { return( true ); }
  1887.     islit = true            // rooms are lit unless otherwise specified
  1888.     isseen = nil            // room has not been seen yet
  1889.     enterRoom( actor ) =    // sent to room as actor is entering it
  1890.     {
  1891.         self.lookAround(( not self.isseen ) or global.verbose );
  1892.         if ( self.islit )
  1893.     {
  1894.         if (not self.isseen) self.firstseen;
  1895.         self.isseen := true;
  1896.     }
  1897.     }
  1898.     roomAction( a, v, d, p, i ) =
  1899.     {
  1900.         if ( self.location ) self.location.roomAction( a, v, d, p, i );
  1901.     }
  1902.  
  1903.     /*
  1904.      *   Whenever a normal object (i.e., one that does not override the
  1905.      *   default doDrop provided by 'thing') is dropped, the actor's
  1906.      *   location is sent roomDrop(object being dropped).  By default, 
  1907.      *   we move the object into this room.
  1908.      */
  1909.     roomDrop( obj ) =
  1910.     {
  1911.         "Dropped. ";
  1912.     obj.moveInto( self );
  1913.     }
  1914.  
  1915.     /*
  1916.      *   Whenever an actor leaves this room, we run through the leaveList.
  1917.      *   This is a list of objects that have registered themselves with us
  1918.      *   via addLeaveList().  For each object in the leaveList, we send
  1919.      *   a "leaving" message, with the actor as the parameter.  It should
  1920.      *   return true if it wants to be removed from the leaveList, nil
  1921.      *   if it wants to stay.
  1922.      */
  1923.     leaveList = []
  1924.     addLeaveList( obj ) =
  1925.     {
  1926.         self.leaveList := self.leaveList + obj;
  1927.     }
  1928.     leaveRoom( actor ) =
  1929.     {
  1930.         local tmplist, thisobj, i, tot;
  1931.  
  1932.         tmplist := self.leaveList;
  1933.     tot := length( tmplist );
  1934.     i := 1;
  1935.         while ( i <= tot )
  1936.         {
  1937.         thisobj := tmplist[i];
  1938.             if ( thisobj.leaving( actor ))
  1939.                 self.leaveList := self.leaveList - thisobj;
  1940.             i := i + 1;
  1941.         }
  1942.     }
  1943.     /*
  1944.      *   lookAround describes the room.  If verbosity is true, the full
  1945.      *   description is given, otherwise an abbreviated description (without
  1946.      *   the room's ldesc) is displayed.
  1947.      */
  1948.     nrmLkAround( verbosity ) =      // lookAround without location status
  1949.     {
  1950.         local l, cur, i, tot;
  1951.  
  1952.         if ( verbosity )
  1953.         {
  1954.             "\n\t"; self.ldesc;
  1955.  
  1956.             l := self.contents;
  1957.         tot := length( l );
  1958.         i := 1;
  1959.             while ( i <= tot )
  1960.             {
  1961.             cur := l[i];
  1962.                 if ( cur.isfixed ) cur.heredesc;
  1963.                 i := i + 1;
  1964.             }
  1965.         }
  1966.         "\n\t";
  1967.         if (itemcnt( self.contents ))
  1968.         {
  1969.             "You see "; listcont( self ); " here. ";
  1970.         }
  1971.         listcontcont( self ); "\n";
  1972.  
  1973.         l := self.contents;
  1974.     tot := length( l );
  1975.     i := 1;
  1976.         while ( i <= tot )
  1977.         {
  1978.         cur := l[i];
  1979.             if ( cur.isactor )
  1980.             {
  1981.                 if ( cur <> Me )
  1982.                 {
  1983.                     "\n\t";
  1984.                     cur.actorDesc;
  1985.                 }
  1986.             }
  1987.             i := i + 1;
  1988.         }
  1989.     }
  1990.     statusLine =
  1991.     {
  1992.         self.sdesc; "\n\t";
  1993.     }
  1994.     lookAround( verbosity ) =
  1995.     {
  1996.         self.statusLine;
  1997.         self.nrmLkAround( verbosity );
  1998.     }
  1999.     
  2000.     /*
  2001.      *   Direction handlers.  The directions are all set up to
  2002.      *   the default, which is no travel allowed.  To make travel
  2003.      *   possible in a direction, just assign a room to the direction
  2004.      *   property.
  2005.      */
  2006.     north = { return( self.noexit ); }
  2007.     south = { return( self.noexit ); }
  2008.     east  = { return( self.noexit ); }
  2009.     west  = { return( self.noexit ); }
  2010.     up    = { return( self.noexit ); }
  2011.     down  = { return( self.noexit ); }
  2012.     ne    = { return( self.noexit ); }
  2013.     nw    = { return( self.noexit ); }
  2014.     se    = { return( self.noexit ); }
  2015.     sw    = { return( self.noexit ); }
  2016.     in    = { return( self.noexit ); }
  2017.     out   = { return( self.noexit ); }
  2018.     
  2019.     /*
  2020.      *   noexit displays a message when the player attempts to travel
  2021.      *   in a direction in which travel is not possible.
  2022.      */
  2023.     noexit = { "%You% can't go that way. "; return( nil ); }
  2024. ;
  2025.  
  2026. /*
  2027.  *  darkroom: room
  2028.  *
  2029.  *  A dark room.  The player must have some object that can act as a
  2030.  *  light source in order to move about and perform most operations
  2031.  *  while in this room.  Note that the room's lights can be turned
  2032.  *  on by setting the room's lightsOn property to true;
  2033.  *  do this instead of setting islit, because islit is
  2034.  *  a method which checks for the presence of a light source.
  2035.  */
  2036. class darkroom: room        // An enterable area which might be dark
  2037.     islit =                 // true ONLY if something is lighting the room
  2038.     {
  2039.         local rem, cur, tot, i;
  2040.  
  2041.     if ( self.lightsOn ) return( true );
  2042.  
  2043.     rem := global.lamplist;
  2044.     tot := length( rem );
  2045.     i := 1;
  2046.     while ( i <= tot )
  2047.     {
  2048.         cur := rem[i];
  2049.         if ( cur.isIn( self ) and cur.islit ) return( true );
  2050.         i := i + 1;
  2051.     }
  2052.     return( nil );
  2053.     }
  2054.     roomAction( actor, v, dobj, prep, io ) =
  2055.     {
  2056.         if ( not self.islit and not v.isDarkVerb )
  2057.     {
  2058.         "%You% can't see a thing. ";
  2059.         exit;
  2060.     }
  2061.     else pass roomAction;
  2062.     }
  2063.     statusLine =
  2064.     {
  2065.         if ( self.islit ) pass statusLine;
  2066.     else "In the dark.";
  2067.     }
  2068.     lookAround( verbosity ) =
  2069.     {
  2070.         if ( self.islit ) pass lookAround;
  2071.     else "It's pitch black. ";
  2072.     }
  2073.     noexit =
  2074.     {
  2075.         if ( self.islit ) pass noexit;
  2076.     else
  2077.     {
  2078.         darkTravel();
  2079.         return( nil );
  2080.     }
  2081.     }
  2082.     roomCheck( v ) =
  2083.     {
  2084.         if ( self.islit or v.isDarkVerb ) return( true );
  2085.     else
  2086.     {
  2087.         "It's pitch black.\n";
  2088.         return( nil );
  2089.     }
  2090.     }
  2091. ;
  2092.  
  2093. /*
  2094.  *  theFloor is a special item that appears in every room (hence
  2095.  *  the non-standard location property).  This object is included
  2096.  *  mostly for completeness, so that the player can refer to the
  2097.  *  floor; otherwise, it doesn't do much.  Dropping an item on the
  2098.  *  floor, for example, moves it to the current room.
  2099.  */
  2100. theFloor: beditem, floatingItem
  2101.     noun = 'floor' 'ground'
  2102.     sdesc = "ground"
  2103.     adesc = "the ground"
  2104.     statusPrep = "on"
  2105.     outOfPrep = "off of"
  2106.     location =
  2107.     {
  2108.         if ( Me.location = self )
  2109.             return( self.sitloc );
  2110.         else
  2111.             return( Me.location );
  2112.     }
  2113.     locationOK = true        // suppress warning about location being a method
  2114.     doSiton( actor ) =
  2115.     {
  2116.         "Okay, %you're% now sitting on "; self.thedesc; ". ";
  2117.         self.sitloc := actor.location;
  2118.         actor.moveInto( self );
  2119.     }
  2120.     doLieon( actor ) =
  2121.     {
  2122.         self.doSiton( actor );
  2123.     }
  2124.     ioPutOn( actor, dobj ) =
  2125.     {
  2126.         dobj.doDrop( actor );
  2127.     }
  2128.     ioPutIn( actor, dobj ) =
  2129.     {
  2130.         dobj.doDrop( actor );
  2131.     }
  2132. ;
  2133.  
  2134. /*
  2135.  *  Actor: fixeditem, movableActor
  2136.  *
  2137.  *  A character in the game.  The maxweight property specifies
  2138.  *  the maximum weight that the character can carry, and the maxbulk
  2139.  *  property specifies the maximum bulk the character can carry.  The
  2140.  *  actorAction(verb, directObject, preposition, indirectObject)
  2141.  *  method specifies what happens when the actor is given a command by
  2142.  *  the player; by default, the actor ignores the command and displays
  2143.  *  a message to this effect.  The isCarrying(object)
  2144.  *  method returns true if the object is being carried by
  2145.  *  the actor.  The actorDesc method displays a message when the
  2146.  *  actor is in the current room; this message is displayed along with
  2147.  *  a room's description when the room is entered or examined.  The
  2148.  *  verGrab(object) method is called when someone tries to
  2149.  *  take an object the actor is carrying; by default, an actor won't
  2150.  *  let other characters take its possessions.
  2151.  *  
  2152.  *  If you want the player to be able to follow the actor when it
  2153.  *  leaves the room, you should define a follower object to shadow
  2154.  *  the character, and set the actor's myfollower property to
  2155.  *  the follower object.  The follower is then automatically
  2156.  *  moved around just behind the actor by the actor's moveInto
  2157.  *  method.
  2158.  *  
  2159.  *  The isHim property should return true if the actor can
  2160.  *  be referred to by the player as "him," and likewise isHer
  2161.  *  should be set to true if the actor can be referred to as "her."
  2162.  *  Note that both or neither can be set; if neither is set, the actor
  2163.  *  can only be referred to as "it," and if both are set, any of "him,''
  2164.  *  "her," or "it'' will be accepted.
  2165.  */
  2166. class Actor: fixeditem, movableActor
  2167. ;
  2168.  
  2169. /*
  2170.  *  movableActor: qcontainer
  2171.  *
  2172.  *  Just like an Actor object, except that the player can
  2173.  *  manipulate the actor like an ordinary item.  Useful for certain
  2174.  *  types of actors, such as small animals.
  2175.  */
  2176. class movableActor: qcontainer // A character in the game
  2177.     isListed = nil          // described separately from room's contents
  2178.     weight = 10             // actors are pretty heavy
  2179.     bulk = 10               // and pretty bulky
  2180.     maxweight = 50          // Weight that can be carried at once
  2181.     maxbulk = 20            // Number of objects that can be carried at once
  2182.     isactor = true          // flag that this is an actor
  2183.     roomCheck( v ) = { return( self.location.roomCheck(v)); }
  2184.     actorAction( v, d, p, i ) =
  2185.     {
  2186.         caps(); self.thedesc; " doesn't appear interested. ";
  2187.         exit;
  2188.     }
  2189.     isCarrying( obj ) = { return( obj.isIn( self )); }
  2190.     actorDesc =
  2191.     {
  2192.         caps(); self.adesc; " is here. ";
  2193.     }
  2194.     verGrab( item ) =
  2195.     {
  2196.         caps(); self.thedesc; " is carrying "; item.thedesc;
  2197.         " and won't let %youm% have it. ";
  2198.     }
  2199.     verDoFollow( actor ) =
  2200.     {
  2201.         "But "; self.thedesc; " is right here! ";
  2202.     }
  2203.     moveInto( obj ) =
  2204.     {
  2205.         if ( self.myfollower ) self.myfollower.moveInto( self.location );
  2206.     pass moveInto;
  2207.     }
  2208.     // these properties are for the format strings
  2209.     fmtYou = "he"
  2210.     fmtYour = "his"
  2211.     fmtYoure = "he's"
  2212.     fmtYoum = "him"
  2213.     fmtYouve = "he's"
  2214.     fmtS = "s"
  2215.     fmtEs = "es"
  2216.     fmtHave = "has"
  2217.     fmtDo = "does"
  2218.     fmtAre = "is"
  2219.     fmtMe = { self.thedesc; }
  2220.     askWord(word, lst) = { return(nil); }
  2221.     verDoAskAbout(actor, iobj) = {}
  2222.     doAskAbout(actor, iobj) =
  2223.     {
  2224.     local lst, i, tot;
  2225.  
  2226.     lst := objwords(2);       // get actual words asked about
  2227.     tot := length(lst);
  2228.     if ((tot = 1 and (find(['it' 'them' 'him' 'her'], lst[1]) <> nil))
  2229.         or tot = 0)
  2230.     {
  2231.         "\"Could you be more specific?\"";
  2232.         return;
  2233.     }
  2234.  
  2235.     // try to find a response for each word
  2236.     for (i := 1 ; i <= tot ; ++i)
  2237.     {
  2238.         if (self.askWord(lst[i], lst))
  2239.             return;
  2240.         }
  2241.  
  2242.     // didn't find anything to talk about
  2243.     self.disavow;
  2244.     }
  2245.     disavow = "\"I don't know much about that.\""
  2246.     verIoPutIn(actor) =
  2247.     {
  2248.         "If you want to give that to << thedesc >>, just say so.";
  2249.     }
  2250.     verIoGiveTo(actor) =
  2251.     {
  2252.     if (actor = self)
  2253.         "That wouldn't accomplish anything!";
  2254.     }
  2255.     ioGiveTo(actor, dobj) =
  2256.     {
  2257.     "\^<<self.thedesc>> rejects the offer.";
  2258.     }
  2259.  
  2260.     // move to a new location, notifying player of coming and going
  2261.     travelTo(room) =
  2262.     {
  2263.     /* do nothing if going nowhere */
  2264.     if (room = nil) return;
  2265.     
  2266.         /* notify player if leaving player's location (and it's not dark) */
  2267.         if (self.location = Me.location and self.location.islit)
  2268.             self.sayLeaving;
  2269.  
  2270.         /* move to my new location */
  2271.         self.moveInto(room);
  2272.  
  2273.         /* notify player if arriving at player's location */
  2274.         if (self.location = Me.location and self.location.islit)
  2275.             self.sayArriving;
  2276.     }
  2277.  
  2278.     // sayLeaving and sayArriving announce the actor's departure and arrival
  2279.     // in the same room as the player.
  2280.     sayLeaving = "\n\t\^<<self.thedesc>> leaves the area."
  2281.     sayArriving = "\n\t\^<<self.thedesc>> enters the area."
  2282.  
  2283.     // this should be used as an actor when ambiguous
  2284.     preferredActor = true
  2285. ;
  2286.  
  2287. /*
  2288.  *  follower: Actor
  2289.  *
  2290.  *  This is a special object that can "shadow" the movements of a
  2291.  *  character as it moves from room to room.  The purpose of a follower
  2292.  *  is to allow the player to follow an actor as it leaves a room by
  2293.  *  typing a "follow" command.  Each actor that is to be followed must
  2294.  *  have its own follower object.  The follower object should
  2295.  *  define all of the same vocabulary words (nouns and adjectives) as the
  2296.  *  actual actor to which it refers.  The follower must also
  2297.  *  define the myactor property to be the Actor object that
  2298.  *  the follower follows.  The follower will always stay
  2299.  *  one room behind the character it follows; no commands are effective
  2300.  *  with a follower except for "follow."
  2301.  */
  2302. class follower: Actor
  2303.     sdesc = { self.myactor.sdesc; }
  2304.     isfollower = true
  2305.     ldesc = { caps(); self.thedesc; " is no longer here. "; }
  2306.     actorAction( v, d, p, i ) = { self.ldesc; exit; }
  2307.     actorDesc = {}
  2308.     myactor = nil   // set to the Actor to be followed
  2309.     verDoFollow( actor ) = {}
  2310.     doFollow( actor ) =
  2311.     {
  2312.         actor.travelTo( self.myactor.location );
  2313.     }
  2314.     dobjGen(a, v, i, p) =
  2315.     {
  2316.         if (v <> followVerb)
  2317.     {
  2318.         "\^<< self.myactor.thedesc >> is no longer here.";
  2319.         exit;
  2320.     }
  2321.     }
  2322.     iobjGen(a, v, d, p) =
  2323.     {
  2324.         "\^<< self.myactor.thedesc >> is no longer here.";
  2325.     exit;
  2326.     }
  2327. ;
  2328.  
  2329. /*
  2330.  *  basicMe: Actor
  2331.  *
  2332.  *  A default implementation of the Me object, which is the
  2333.  *  player character.  adv.t defines basicMe instead of
  2334.  *  Me to allow your game to override parts of the default
  2335.  *  implementation while still using the rest, and without changing
  2336.  *  adv.t itself.  To use basicMe unchanged as your player
  2337.  *  character, include this in your game:  "Me: basicMe;".
  2338.  *  
  2339.  *  The basicMe object defines all of the methods and properties
  2340.  *  required for an actor, with appropriate values for the player
  2341.  *  character.  The nouns "me" and "myself'' are defined ("I''
  2342.  *  is not defined, because it conflicts with the "inventory"
  2343.  *  command's minimal abbreviation of "i" in certain circumstances,
  2344.  *  and is generally not compatible with the syntax of most player
  2345.  *  commands anyway).  The sdesc is "you"; the thedesc
  2346.  *  and adesc are "yourself," which is appropriate for most
  2347.  *  contexts.  The maxbulk and maxweight properties are
  2348.  *  set to 10 each; a more sophisticated Me might include the
  2349.  *  player's state of health in determining the maxweight and
  2350.  *  maxbulk properties.
  2351.  */
  2352. class basicMe: Actor, floatingItem
  2353.     roomCheck( v ) = { return( self.location.roomCheck( v )); }
  2354.     noun = 'me' 'myself'
  2355.     sdesc = "you"
  2356.     thedesc = "yourself"
  2357.     adesc = "yourself"
  2358.     ldesc = "You look about the same as always. "
  2359.     maxweight = 10
  2360.     maxbulk = 10
  2361.     verDoFollow( actor ) =
  2362.     {
  2363.         if ( actor = self ) "You can't follow yourself! ";
  2364.     }
  2365.     actorAction( verb, dobj, prep, iobj ) = 
  2366.     {
  2367.     }
  2368.     travelTo( room ) =
  2369.     {
  2370.         if ( room )
  2371.         {
  2372.         if ( room.isobstacle )
  2373.         {
  2374.             self.travelTo( room.destination );
  2375.         }
  2376.         else if ( not ( self.location.islit or room.islit ))
  2377.         {
  2378.             darkTravel();
  2379.         }
  2380.         else
  2381.         {
  2382.                 if ( self.location ) self.location.leaveRoom( self );
  2383.                 self.location := room;
  2384.                 room.enterRoom( self );
  2385.         }
  2386.         }
  2387.     }
  2388.     moveInto( room ) =
  2389.     {
  2390.         self.location := room;
  2391.     }
  2392.     ioGiveTo(actor, dobj) =
  2393.     {
  2394.     "You accept <<dobj.thedesc>> from <<actor.thedesc>>.";
  2395.     dobj.moveInto(Me);
  2396.     }
  2397.  
  2398.     // these properties are for the format strings
  2399.     fmtYou = "you"
  2400.     fmtYour = "your"
  2401.     fmtYoure = "you're"
  2402.     fmtYoum = "you"
  2403.     fmtYouve = "you've"
  2404.     fmtS = ""
  2405.     fmtEs = ""
  2406.     fmtHave = "have"
  2407.     fmtDo = "do"
  2408.     fmtAre = "are"
  2409.     fmtMe = "me"
  2410. ;
  2411.  
  2412. /*
  2413.  *  decoration: fixeditem
  2414.  *
  2415.  *  An item that doesn't have any function in the game, apart from
  2416.  *  having been mentioned in the room description.  These items
  2417.  *  are immovable and can't be manipulated in any way, but can be
  2418.  *  referred to and inspected.  Liberal use of decoration items
  2419.  *  can improve a game's playability by helping the parser recognize
  2420.  *  all the words the game uses in its descriptions of rooms.
  2421.  */
  2422. class decoration: fixeditem
  2423.     ldesc = "That's not important."
  2424.     dobjGen(a, v, i, p) =
  2425.     {
  2426.         if (v <> inspectVerb)
  2427.     {
  2428.         "\^<<self.thedesc>> isn't important.";
  2429.         exit;
  2430.     }
  2431.     }
  2432.     iobjGen(a, v, d, p) =
  2433.     {
  2434.         "\^<<self.thedesc>> isn't important.";
  2435.     exit;
  2436.     }
  2437. ;
  2438.  
  2439. /*
  2440.  *  distantItem: fixeditem
  2441.  *
  2442.  *  This is an item that is too far away to manipulate, but can be seen.
  2443.  *  The class uses dobjGen and iobjGen to prevent any verbs from being
  2444.  *  used on the object apart from inspectVerb; using any other verb results
  2445.  *  in the message "It's too far away."  Instances of this class should
  2446.  *  provide the normal item properties:  sdesc, ldesc, location,
  2447.  *  and vocabulary.
  2448.  */
  2449. class distantItem: fixeditem
  2450.     dobjGen(a, v, i, p) =
  2451.     {
  2452.         if (v <> inspectVerb)
  2453.         {
  2454.             "It's too far away.";
  2455.             exit;
  2456.         }
  2457.     }
  2458.     iobjGen(a, v, d, p) = { self.dobjGen(a, v, d, p); }
  2459. ;
  2460.  
  2461. /*
  2462.  *  buttonitem: fixeditem
  2463.  *
  2464.  *  A button (the type you push).  The individual button's action method
  2465.  *  doPush(actor), which must be specified in
  2466.  *  the button, carries out the function of the button.  Note that
  2467.  *  all buttons have the noun "button" defined.
  2468.  */
  2469. class buttonitem: fixeditem
  2470.     noun = 'button'
  2471.     plural = 'buttons'
  2472.     verDoPush( actor ) = {}
  2473. ;
  2474.  
  2475. /*
  2476.  *  clothingItem: item
  2477.  *
  2478.  *  Something that can be worn.  By default, the only thing that
  2479.  *  happens when the item is worn is that its isworn property
  2480.  *  is set to true.  If you want more to happen, override the
  2481.  *  doWear(actor) property.  Note that, when a clothingItem
  2482.  *  is being worn, certain operations will cause it to be removed (for
  2483.  *  example, dropping it causes it to be removed).  If you want
  2484.  *  something else to happen, override the checkDrop method;
  2485.  *  if you want to disallow such actions while the object is worn,
  2486.  *  use an exit statement in the checkDrop method.
  2487.  */
  2488. class clothingItem: item
  2489.     checkDrop =
  2490.     {
  2491.         if ( self.isworn )
  2492.     {
  2493.         "(Taking off "; self.thedesc; " first)\n";
  2494.         self.isworn := nil;
  2495.     }
  2496.     }
  2497.     doDrop( actor ) =
  2498.     {
  2499.         self.checkDrop;
  2500.     pass doDrop;
  2501.     }
  2502.     doPutIn( actor, io ) =
  2503.     {
  2504.         self.checkDrop;
  2505.     pass doPutIn;
  2506.     }
  2507.     doPutOn( actor, io ) =
  2508.     {
  2509.         self.checkDrop;
  2510.     pass doPutOn;
  2511.     }
  2512.     doGiveTo( actor, io ) =
  2513.     {
  2514.         self.checkDrop;
  2515.     pass doGiveTo;
  2516.     }
  2517.     doThrowAt( actor, io ) =
  2518.     {
  2519.         self.checkDrop;
  2520.     pass doThrowAt;
  2521.     }
  2522.     doThrowTo( actor, io ) =
  2523.     {
  2524.         self.checkDrop;
  2525.     pass doThrowTo;
  2526.     }
  2527.     doThrow( actor ) =
  2528.     {
  2529.         self.checkDrop;
  2530.     pass doThrow;
  2531.     }
  2532.     moveInto( obj ) =
  2533.     {
  2534.         /*
  2535.      *   Catch any other movements with moveInto; this won't stop the
  2536.      *   movement from happening, but it will prevent any anamolous
  2537.      *   consequences caused by the object moving but still being worn.
  2538.      */
  2539.         self.isworn := nil;
  2540.     pass moveInto;
  2541.     }
  2542.     verDoWear( actor ) =
  2543.     {
  2544.         if ( self.isworn )
  2545.         {
  2546.             "%You're% already wearing "; self.thedesc; "! ";
  2547.         }
  2548.         else if ( not actor.isCarrying( self ))
  2549.         {
  2550.             "%You% %do%n't have "; self.thedesc; ". ";
  2551.         }
  2552.     }
  2553.     doWear( actor ) =
  2554.     {
  2555.         "Okay, %you're% now wearing "; self.thedesc; ". ";
  2556.         self.isworn := true;
  2557.     }
  2558.     verDoUnwear( actor ) =
  2559.     {
  2560.         if ( not self.isworn )
  2561.         {
  2562.             "%You're% not wearing "; self.thedesc; ". ";
  2563.         }
  2564.     }
  2565.     verDoTake(actor) =
  2566.     {
  2567.         if (self.isworn) self.verDoUnwear(actor);
  2568.     else pass verDoTake;
  2569.     }
  2570.     doTake(actor) =
  2571.     {
  2572.         if (self.isworn) self.doUnwear(actor);
  2573.     else pass doTake;
  2574.     }
  2575.     doUnwear( actor ) =
  2576.     {
  2577.         "Okay, %you're% no longer wearing "; self.thedesc; ". ";
  2578.         self.isworn := nil;
  2579.     }
  2580.     doSynonym('Unwear') = 'Unboard'
  2581. ;
  2582.  
  2583. /*
  2584.  *  obstacle: object
  2585.  *
  2586.  *  An obstacle is used in place of a room for a direction
  2587.  *  property.  The destination property specifies the room that
  2588.  *  is reached if the obstacle is successfully negotiated; when the
  2589.  *  obstacle is not successfully negotiated, destination should
  2590.  *  display an appropriate message and return nil.
  2591.  */
  2592. class obstacle: object
  2593.     isobstacle = true
  2594. ;
  2595.  
  2596. /*
  2597.  *  doorway: fixeditem, obstacle
  2598.  *
  2599.  *  A doorway is an obstacle that impedes progress when it is closed.
  2600.  *  When the door is open (isopen is true), the user ends up in
  2601.  *  the room specified in the doordest property upon going through
  2602.  *  the door.  Since a doorway is an obstacle, use the door object for
  2603.  *  a direction property of the room containing the door.
  2604.  *  
  2605.  *  If noAutoOpen is not set to true, the door will automatically
  2606.  *  be opened when the player tries to walk through the door, unless the
  2607.  *  door is locked (islocked = true).  If the door is locked,
  2608.  *  it can be unlocked simply by typing "unlock door", unless the
  2609.  *  mykey property is set, in which case the object specified in
  2610.  *  mykey must be used to unlock the door.  Note that the door can
  2611.  *  only be relocked by the player under the circumstances that allow
  2612.  *  unlocking, plus the property islockable must be set to true.
  2613.  *  By default, the door is closed; set isopen to true if the door
  2614.  *  is to start out open (and be sure to open the other side as well).
  2615.  *  
  2616.  *  otherside specifies the corresponding doorway object in the
  2617.  *  destination room (doordest), if any.  If otherside is
  2618.  *  specified, its isopen and islocked properties will be
  2619.  *  kept in sync automatically.
  2620.  */
  2621. class doorway: fixeditem, obstacle
  2622.     isdoor = true           // Item can be opened and closed
  2623.     destination =
  2624.     {
  2625.         if ( self.isopen ) return( self.doordest );
  2626.     else if ( not self.islocked and not self.noAutoOpen )
  2627.     {
  2628.         self.isopen := true;
  2629.         if ( self.otherside ) self.otherside.isopen := true;
  2630.         "(Opening << self.thedesc >>)\n";
  2631.         return( self.doordest );
  2632.     }
  2633.     else
  2634.     {
  2635.         "%You%'ll have to open << self.thedesc >> first. ";
  2636.         setit( self );
  2637.         return( nil );
  2638.     }
  2639.     }
  2640.     verDoOpen( actor ) =
  2641.     {
  2642.         if ( self.isopen ) "It's already open. ";
  2643.     else if ( self.islocked ) "It's locked. ";
  2644.     }
  2645.     doOpen( actor ) =
  2646.     {
  2647.         "Opened. ";
  2648.     self.isopen := true;
  2649.     if ( self.otherside ) self.otherside.isopen := true;
  2650.     }
  2651.     verDoClose( actor ) =
  2652.     {
  2653.         if ( not self.isopen ) "It's already closed. ";
  2654.     }
  2655.     doClose( actor ) =
  2656.     {
  2657.         "Closed. ";
  2658.     self.isopen := nil;
  2659.     if ( self.otherside ) self.otherside.isopen := nil;
  2660.     }
  2661.     verDoLock( actor ) =
  2662.     {
  2663.         if ( self.islocked ) "It's already locked! ";
  2664.     else if ( not self.islockable ) "It can't be locked. ";
  2665.     else if ( self.isopen ) "%You%'ll have to close it first. ";
  2666.     }
  2667.     doLock( actor ) =
  2668.     {
  2669.         if ( self.mykey = nil )
  2670.     {
  2671.         "Locked. ";
  2672.         self.islocked := true;
  2673.         if ( self.otherside ) self.otherside.islocked := true;
  2674.     }
  2675.     else
  2676.             askio( withPrep );
  2677.     }
  2678.     verDoUnlock( actor ) =
  2679.     {
  2680.         if ( not self.islocked ) "It's not locked! ";
  2681.     }
  2682.     doUnlock( actor ) =
  2683.     {
  2684.         if ( self.mykey = nil )
  2685.     {
  2686.         "Unlocked. ";
  2687.         self.islocked := nil;
  2688.         if ( self.otherside ) self.otherside.islocked := nil;
  2689.     }
  2690.     else
  2691.         askio( withPrep );
  2692.     }
  2693.     verDoLockWith( actor, io ) =
  2694.     {
  2695.         if ( self.islocked ) "It's already locked. ";
  2696.     else if ( not self.islockable ) "It can't be locked. ";
  2697.     else if ( self.mykey = nil )
  2698.         "%You% %do%n't need anything to lock it. ";
  2699.     else if ( self.isopen ) "%You%'ll have to close it first. ";
  2700.     }
  2701.     doLockWith( actor, io ) =
  2702.     {
  2703.         if ( io = self.mykey )
  2704.     {
  2705.         "Locked. ";
  2706.         self.islocked := true;
  2707.         if ( self.otherside ) self.otherside.islocked := true;
  2708.     }
  2709.     else "It doesn't fit the lock. ";
  2710.     }
  2711.     verDoUnlockWith( actor, io ) =
  2712.     {
  2713.         if ( not self.islocked ) "It's not locked! ";
  2714.     else if ( self.mykey = nil )
  2715.         "%You% %do%n't need anything to unlock it. ";
  2716.     }
  2717.     doUnlockWith( actor, io ) =
  2718.     {
  2719.         if ( io = self.mykey )
  2720.     {
  2721.         "Unlocked. ";
  2722.         self.islocked := nil;
  2723.         if ( self.otherside ) self.otherside.islocked := nil;
  2724.     }
  2725.     else "It doesn't fit the lock. ";
  2726.     }
  2727.     ldesc =
  2728.     {
  2729.     if ( self.isopen ) "It's open. ";
  2730.     else
  2731.     {
  2732.         if ( self.islocked ) "It's closed and locked. ";
  2733.         else "It's closed. ";
  2734.     }
  2735.     }
  2736. ;
  2737.  
  2738. /*
  2739.  *  lockableDoorway: doorway
  2740.  *
  2741.  *  This is just a normal doorway with the islockable and
  2742.  *  islocked properties set to true.  Fill in the other
  2743.  *  properties (otherside and doordest) as usual.  If
  2744.  *  the door has a key, set property mykey to the key object.
  2745.  */
  2746. class lockableDoorway: doorway
  2747.     islockable = true
  2748.     islocked = true
  2749. ;
  2750.  
  2751. /*
  2752.  *  vehicle: item, nestedroom
  2753.  *
  2754.  *  This is an object that an actor can board.  An actor cannot go
  2755.  *  anywhere while on board a vehicle (except where the vehicle goes);
  2756.  *  the actor must get out first.
  2757.  */
  2758. class vehicle: item, nestedroom
  2759.     reachable = ([] + self)
  2760.     isvehicle = true
  2761.     verDoEnter( actor ) = { self.verDoBoard( actor ); }
  2762.     doEnter( actor ) = { self.doBoard( actor ); }
  2763.     verDoBoard( actor ) =
  2764.     {
  2765.         if ( actor.location = self )
  2766.         {
  2767.             "%You're% already in "; self.thedesc; "! ";
  2768.         }
  2769.     else if (actor.isCarrying(self))
  2770.     {
  2771.         "%You%'ll have to drop <<thedesc>> first!";
  2772.     }
  2773.     }
  2774.     doBoard( actor ) =
  2775.     {
  2776.         "Okay, %you're% now in "; self.thedesc; ". ";
  2777.         actor.moveInto( self );
  2778.     }
  2779.     noexit =
  2780.     {
  2781.         "%You're% not going anywhere until %you% get%s% out of ";
  2782.       self.thedesc; ". ";
  2783.         return( nil );
  2784.     }
  2785.     out = ( self.location )
  2786.     verDoTake(actor) =
  2787.     {
  2788.         if (actor.isIn(self))
  2789.         "%You%'ll have to get <<self.outOfPrep>> <<self.thedesc>> first.";
  2790.     else
  2791.         pass verDoTake;
  2792.     }
  2793.     dobjGen(a, v, i, p) =
  2794.     {
  2795.         if (a.isIn(self) and v <> inspectVerb and v <> getOutVerb
  2796.         and v <> outVerb)
  2797.     {
  2798.         "%You%'ll have to get out of << thedesc >> first.";
  2799.         exit;
  2800.     }
  2801.     }
  2802.     iobjGen(a, v, d, p) =
  2803.     {
  2804.         if (a.isIn(self) and v <> putVerb)
  2805.     {
  2806.         "%You%'ll have to get out of << thedesc >> first.";
  2807.         exit;
  2808.     }
  2809.     }
  2810. ;
  2811.  
  2812. /*
  2813.  *  surface: item
  2814.  *
  2815.  *  Objects can be placed on a surface.  Apart from using the
  2816.  *  preposition "on" rather than "in'' to refer to objects
  2817.  *  contained by the object, a surface is identical to a
  2818.  *  container.  Note: an object cannot be both a
  2819.  *  surface and a container, because there is no
  2820.  *  distinction between the two internally.
  2821.  */
  2822. class surface: item
  2823.     issurface = true        // Item can hold objects on its surface
  2824.     ldesc =
  2825.     {
  2826.         if (itemcnt( self.contents ))
  2827.         {
  2828.             "On "; self.thedesc; " %you% see%s% "; listcont( self ); ". ";
  2829.         }
  2830.         else
  2831.         {
  2832.             "There's nothing on "; self.thedesc; ". ";
  2833.         }
  2834.     }
  2835.     verIoPutOn( actor ) = {}
  2836.     ioPutOn( actor, dobj ) =
  2837.     {
  2838.         dobj.doPutOn( actor, self );
  2839.     }
  2840. ;
  2841.  
  2842. /*
  2843.  *  container: item
  2844.  *
  2845.  *  This object can contain other objects.  The iscontainer property
  2846.  *  is set to true.  The default ldesc displays a list of the
  2847.  *  objects inside the container, if any.  The maxbulk property
  2848.  *  specifies the maximum amount of bulk the container can contain.
  2849.  */
  2850. class container: item
  2851.     maxbulk = 10            // maximum bulk the container can contain
  2852.     isopen = true           // in fact, it can't be closed at all
  2853.     iscontainer = true      // Item can contain other items
  2854.     ldesc =
  2855.     {
  2856.         if ( self.contentsVisible and itemcnt( self.contents ) <> 0 )
  2857.         {
  2858.             "In "; self.thedesc; " %you% see%s% "; listcont( self ); ". ";
  2859.         }
  2860.         else
  2861.         {
  2862.             "There's nothing in "; self.thedesc; ". ";
  2863.         }
  2864.     }
  2865.     verIoPutIn( actor ) =
  2866.     {
  2867.     }
  2868.     ioPutIn( actor, dobj ) =
  2869.     {
  2870.         if (addbulk( self.contents ) + dobj.bulk > self.maxbulk )
  2871.         {
  2872.             "%You% can't fit that in "; self.thedesc; ". ";
  2873.         }
  2874.         else
  2875.         {
  2876.         dobj.doPutIn( actor, self );
  2877.         }
  2878.     }
  2879.     verDoLookin( actor ) = {}
  2880.     doLookin( actor ) =
  2881.     {
  2882.         self.ldesc;
  2883.     }
  2884. ;
  2885.  
  2886. /*
  2887.  *  openable: container
  2888.  *
  2889.  *  A container that can be opened and closed.  The isopenable
  2890.  *  property is set to true.  The default ldesc displays
  2891.  *  the contents of the container if the container is open, otherwise
  2892.  *  a message saying that the object is closed.
  2893.  */
  2894. class openable: container
  2895.     contentsReachable = { return( self.isopen ); }
  2896.     contentsVisible = { return( self.isopen ); }
  2897.     isopenable = true
  2898.     ldesc =
  2899.     {
  2900.         caps(); self.thedesc;
  2901.         if ( self.isopen )
  2902.     {
  2903.         " is open. ";
  2904.         pass ldesc;
  2905.     }
  2906.         else
  2907.     {
  2908.         " is closed. ";
  2909.  
  2910.         /* if it's transparent, list its contents anyway */
  2911.         if (isclass(self, transparentItem)) pass ldesc;
  2912.     }
  2913.     }
  2914.     isopen = true
  2915.     verDoOpen( actor ) =
  2916.     {
  2917.         if ( self.isopen )
  2918.     {
  2919.         caps(); self.thedesc; " is already open! ";
  2920.     }
  2921.     }
  2922.     doOpen( actor ) =
  2923.     {
  2924.         if (itemcnt( self.contents ))
  2925.     {
  2926.         "Opening "; self.thedesc; " reveals "; listcont( self ); ". ";
  2927.     }
  2928.     else "Opened. ";
  2929.     self.isopen := true;
  2930.     }
  2931.     verDoClose( actor ) =
  2932.     {
  2933.         if ( not self.isopen )
  2934.     {
  2935.         caps(); self.thedesc; " is already closed! ";
  2936.     }
  2937.     }
  2938.     doClose( actor ) =
  2939.     {
  2940.         "Closed. ";
  2941.     self.isopen := nil;
  2942.     }
  2943.     verIoPutIn( actor ) =
  2944.     {
  2945.         if ( not self.isopen )
  2946.     {
  2947.         caps(); self.thedesc; " is closed. ";
  2948.     }
  2949.     }
  2950.     verDoLookin( actor ) =
  2951.     {
  2952.         /* we can look in it if either it's open or it's transparent */
  2953.         if (not self.isopen and not isclass(self, transparentItem))
  2954.            "It's closed. ";
  2955.     }
  2956. ;
  2957.  
  2958. /*
  2959.  *  qcontainer: container
  2960.  *
  2961.  *  A "quiet" container:  its contents are not listed when it shows
  2962.  *  up in a room description or inventory list.  The isqcontainer
  2963.  *  property is set to true.
  2964.  */
  2965. class qcontainer: container
  2966.     isqcontainer = true
  2967. ;
  2968.  
  2969. /*
  2970.  *  lockable: openable
  2971.  *
  2972.  *  A container that can be locked and unlocked.  The islocked
  2973.  *  property specifies whether the object can be opened or not.  The
  2974.  *  object can be locked and unlocked without the need for any other
  2975.  *  object; if you want a key to be involved, use a keyedLockable.
  2976.  */
  2977. class lockable: openable
  2978.     verDoOpen( actor ) =
  2979.     {
  2980.         if ( self.islocked )
  2981.         {
  2982.             "It's locked. ";
  2983.         }
  2984.         else pass verDoOpen;
  2985.     }
  2986.     verDoLock( actor ) =
  2987.     {
  2988.         if ( self.islocked )
  2989.         {
  2990.             "It's already locked! ";
  2991.         }
  2992.     }
  2993.     doLock( actor ) =
  2994.     {
  2995.         if ( self.isopen )
  2996.         {
  2997.             "%You%'ll have to close "; self.thedesc; " first. ";
  2998.         }
  2999.         else
  3000.         {
  3001.             "Locked. ";
  3002.             self.islocked := true;
  3003.         }
  3004.     }
  3005.     verDoUnlock( actor ) =
  3006.     {
  3007.         if ( not self.islocked ) "It's not locked! ";
  3008.     }
  3009.     doUnlock( actor ) =
  3010.     {
  3011.         "Unlocked. ";
  3012.         self.islocked := nil;
  3013.     }
  3014.     verDoLockWith( actor, io ) =
  3015.     {
  3016.         if ( self.islocked ) "It's already locked. ";
  3017.     }
  3018.     verDoUnlockWith( actor, io ) =
  3019.     {
  3020.         if ( not self.islocked ) "It's not locked! ";
  3021.     }
  3022. ;
  3023.  
  3024. /*
  3025.  *  keyedLockable: lockable
  3026.  *
  3027.  *  This subclass of lockable allows you to create an object
  3028.  *  that can only be locked and unlocked with a corresponding key.
  3029.  *  Set the property mykey to the keyItem object that can
  3030.  *  lock and unlock the object.
  3031.  */
  3032. class keyedLockable: lockable
  3033.     mykey = nil     // set 'mykey' to the key which locks/unlocks me
  3034.     doLock( actor ) =
  3035.     {
  3036.         askio( withPrep );
  3037.     }
  3038.     doUnlock( actor ) =
  3039.     {
  3040.         askio( withPrep );
  3041.     }
  3042.     doLockWith( actor, io ) =
  3043.     {
  3044.         if ( self.isopen )
  3045.         {
  3046.             "%You% can't lock << self.thedesc >> when it's open. ";
  3047.         }
  3048.         else if ( io = self.mykey )
  3049.         {
  3050.             "Locked. ";
  3051.             self.islocked := true;
  3052.         }
  3053.         else "It doesn't fit the lock. ";
  3054.     }
  3055.     doUnlockWith( actor, io ) =
  3056.     {
  3057.         if ( io = self.mykey )
  3058.         {
  3059.             "Unlocked. ";
  3060.             self.islocked := nil;
  3061.         }
  3062.         else "It doesn't fit the lock. ";
  3063.     }
  3064. ;
  3065.  
  3066. /*
  3067.  *  keyItem: item
  3068.  *
  3069.  *  This is an object that can be used as a key for a keyedLockable
  3070.  *  or lockableDoorway object.  It otherwise behaves as an ordinary item.
  3071.  */
  3072. class keyItem: item
  3073.     verIoUnlockWith( actor ) = {}
  3074.     ioUnlockWith( actor, dobj ) =
  3075.     {
  3076.         dobj.doUnlockWith( actor, self );
  3077.     }
  3078.     verIoLockWith( actor ) = {}
  3079.     ioLockWith( actor, dobj ) =
  3080.     {
  3081.         dobj.doLockWith( actor, self );
  3082.     }
  3083. ;
  3084.  
  3085. /*
  3086.  *  seethruItem: item
  3087.  *
  3088.  *  This is an object that the player can look through, such as a window.
  3089.  *  The thrudesc method displays a message for when the player looks
  3090.  *  through the object (with a command such as "look through window").
  3091.  *  Note this is not the same as a transparentItem, whose contents
  3092.  *  are visible from outside the object.
  3093.  */
  3094. class seethruItem: item
  3095.     verDoLookthru(actor) = {}
  3096.     doLookthru(actor) = { self.thrudesc; }
  3097. ;
  3098.  
  3099.  
  3100. /*
  3101.  *  transparentItem: item
  3102.  *
  3103.  *  An object whose contents are visible, even when the object is
  3104.  *  closed.  Whether the contents are reachable is decided in the
  3105.  *  normal fashion.  This class is useful for items such as glass
  3106.  *  bottles, whose contents can be seen when the bottle is closed
  3107.  *  but cannot be reached.
  3108.  */
  3109. class transparentItem: item
  3110.     contentsVisible = { return( true ); }
  3111.     ldesc =
  3112.     {
  3113.         if (self.contentsVisible and itemcnt(self.contents) <> 0)
  3114.         {
  3115.             "In "; self.thedesc; " %you% see%s% "; listcont(self); ". ";
  3116.         }
  3117.         else
  3118.         {
  3119.             "There's nothing in "; self.thedesc; ". ";
  3120.         }
  3121.     }
  3122.     verGrab( obj ) =
  3123.     {
  3124.         if ( self.isopenable and not self.isopen )
  3125.             "%You% will have to open << self.thedesc >> first. ";
  3126.     }
  3127.     doOpen( actor ) =
  3128.     {
  3129.         self.isopen := true;
  3130.         "Opened. ";
  3131.     }
  3132.     verDoLookin(actor) = {}
  3133.     doLookin(actor) = { self.ldesc; }
  3134. ;
  3135.  
  3136. /*
  3137.  *  basicNumObj: object
  3138.  *
  3139.  *  This object provides a default implementation for numObj.
  3140.  *  To use this default unchanged in your game, include in your
  3141.  *  game this line:  "numObj: basicNumObj".
  3142.  */
  3143. class basicNumObj: object   // when a number is used in a player command,
  3144.     value = 0               //  this is set to its value
  3145.     sdesc = "<<value>>"
  3146.     adesc = "a number"
  3147.     thedesc = "the number <<value>>"
  3148.     verDoTypeOn( actor, io ) = {}
  3149.     doTypeOn( actor, io ) = { "\"Tap, tap, tap, tap...\" "; }
  3150.     verIoTurnTo( actor ) = {}
  3151.     ioTurnTo( actor, dobj ) = { dobj.doTurnTo( actor, self ); }
  3152. ;
  3153.  
  3154. /*
  3155.  *  basicStrObj: object
  3156.  *
  3157.  *  This object provides a default implementation for strObj.
  3158.  *  To use this default unchanged in your game, include in your
  3159.  *  game this line:  "strObj: basicStrObj".
  3160.  */
  3161. class basicStrObj: object   // when a string is used in a player command,
  3162.     value = ''              //  this is set to its value
  3163.     sdesc = "\"<<value>>\""
  3164.     adesc = "\"<<value>>\""
  3165.     thedesc = "\"<<value>>\""
  3166.     verDoTypeOn( actor, io ) = {}
  3167.     doTypeOn( actor, io ) = { "\"Tap, tap, tap, tap...\" "; }
  3168.     doSynonym('TypeOn') = 'EnterOn' 'EnterIn' 'EnterWith'
  3169.     verDoSave( actor ) = {}
  3170.     saveGame(actor) =
  3171.     {
  3172.         if (save( self.value ))
  3173.     {
  3174.             "Save failed. ";
  3175.         return nil;
  3176.     }
  3177.         else
  3178.     {
  3179.             "Saved. ";
  3180.         return true;
  3181.     }
  3182.     }
  3183.     doSave( actor ) =
  3184.     {
  3185.     self.saveGame(actor);
  3186.     abort;
  3187.     }
  3188.     verDoRestore( actor ) = {}
  3189.     restoreGame(actor) =
  3190.     {
  3191.         if (restore( self.value ))
  3192.     {
  3193.             "Restore failed. ";
  3194.         return nil;
  3195.     }
  3196.         else
  3197.     {
  3198.             "Restored.\b";
  3199.         scoreStatus( global.score, global.turnsofar );
  3200.         Me.location.lookAround(true);
  3201.         return true;
  3202.     }
  3203.     }
  3204.     doRestore( actor ) =
  3205.     {
  3206.     self.restoreGame(actor);
  3207.         abort;
  3208.     }
  3209.     verDoScript( actor ) = {}
  3210.     startScripting(actor) =
  3211.     {
  3212.         logging( self.value );
  3213.         "Writing script file. ";
  3214.     }
  3215.     doScript( actor ) =
  3216.     {
  3217.     self.startScripting(actor);
  3218.         abort;
  3219.     }
  3220.     verDoSay( actor ) = {}
  3221.     doSay( actor ) =
  3222.     {
  3223.         "Okay, \""; say( self.value ); "\".";
  3224.     }
  3225. ;
  3226.  
  3227. /*
  3228.  *  deepverb: object
  3229.  *
  3230.  *  A "verb object" that is referenced by the parser when the player
  3231.  *  uses an associated vocabulary word.  A deepverb contains both
  3232.  *  the vocabulary of the verb and a description of available syntax.
  3233.  *  The verb property lists the verb vocabulary words;
  3234.  *  one word (such as 'take') or a pair (such as 'pick up')
  3235.  *  can be used.  In the latter case, the second word must be a
  3236.  *  preposition, and may move to the end of the sentence in a player's
  3237.  *  command, as in "pick it up."  The action(actor)
  3238.  *  method specifies what happens when the verb is used without any
  3239.  *  objects; its absence specifies that the verb cannot be used without
  3240.  *  an object.  The doAction specifies the root of the message
  3241.  *  names (in single quotes) sent to the direct object when the verb
  3242.  *  is used with a direct object; its absence means that a single object
  3243.  *  is not allowed.  Likewise, the ioAction(preposition)
  3244.  *  specifies the root of the message name sent to the direct and
  3245.  *  indirect objects when the verb is used with both a direct and
  3246.  *  indirect object; its absence means that this syntax is illegal.
  3247.  *  Several ioAction properties may be present:  one for each
  3248.  *  preposition that can be used with an indirect object with the verb.
  3249.  *  
  3250.  *  The validDo(actor, object, seqno) method returns true
  3251.  *  if the indicated object is valid as a direct object for this actor.
  3252.  *  The validIo(actor, object, seqno) method does likewise
  3253.  *  for indirect objects.  The seqno parameter is a "sequence
  3254.  *  number," starting with 1 for the first object tried for a given
  3255.  *  verb, 2 for the second, and so forth; this parameter is normally
  3256.  *  ignored, but can be used for some special purposes.  For example,
  3257.  *  askVerb does not distinguish between objects matching vocabulary
  3258.  *  words, and therefore accepts only the first from a set of ambiguous
  3259.  *  objects.  These methods do not normally need to be changed; by
  3260.  *  default, they return true if the object is accessible to the
  3261.  *  actor.
  3262.  *  
  3263.  *  The doDefault(actor, prep, indirectObject) and
  3264.  *  ioDefault(actor, prep) methods return a list of the
  3265.  *  default direct and indirect objects, respectively.  These lists
  3266.  *  are used for determining which objects are meant by "all" and which
  3267.  *  should be used when the player command is missing an object.  These
  3268.  *  normally return a list of all objects that are applicable to the
  3269.  *  current command.
  3270.  *  
  3271.  *  The validDoList(actor, prep, indirectObject) and
  3272.  *  validIoList(actor, prep, directObject) methods return
  3273.  *  a list of all of the objects for which validDo would be true.
  3274.  *  Remember to include floating objects, which are generally
  3275.  *  accessible.  Note that the objects returned by this list will
  3276.  *  still be submitted by the parser to validDo, so it's okay for
  3277.  *  this routine to return too many objects.  In fact, this
  3278.  *  routine is entirely unnecessary; if you omit it altogether, or
  3279.  *  make it return nil, the parser will simply submit every
  3280.  *  object matching the player's vocabulary words to validDo.
  3281.  *  The reason to provide this method is that it can significantly
  3282.  *  improve parsing speed when the game has lots of objects that
  3283.  *  all have the same vocabulary word, because it cuts down on the
  3284.  *  number of times that validDo has to be called (each call
  3285.  *  to validDo is fairly time-consuming).
  3286.  */
  3287. class deepverb: object                // A deep-structure verb.
  3288.     validDo( actor, obj, seqno ) =
  3289.     {
  3290.         return( obj.isReachable( actor ));
  3291.     }
  3292.     validDoList(actor, prep, iobj) =
  3293.     {
  3294.     local ret;
  3295.     local loc;
  3296.  
  3297.     loc := actor.location;
  3298.     while (loc.location) loc := loc.location;
  3299.     ret := visibleList(actor) + visibleList(loc)
  3300.            + global.floatingList;
  3301.     return(ret);
  3302.     }
  3303.     validIo( actor, obj, seqno ) =
  3304.     {
  3305.         return( obj.isReachable( actor ));
  3306.     }
  3307.     validIoList(actor, prep, dobj) = (self.validDoList(actor, prep, dobj))
  3308.     doDefault( actor, prep, io ) =
  3309.     {
  3310.         return( actor.contents + actor.location.contents );
  3311.     }
  3312.     ioDefault( actor, prep ) =
  3313.     {
  3314.         return( actor.contents + actor.location.contents );
  3315.     }
  3316. ;
  3317.  
  3318. /*
  3319.    Dark verb - a verb that can be used in the dark.  Travel verbs
  3320.    are all dark verbs, as are system verbs (quit, save, etc.).
  3321.    In addition, certain special verbs are usable in the dark:  for
  3322.    example, you can drop objects you are carrying, and you can turn
  3323.    on light sources you are carrying. 
  3324. */
  3325.  
  3326. class darkVerb: deepverb
  3327.    isDarkVerb = true
  3328. ;
  3329.  
  3330. /*
  3331.  *   Various verbs.
  3332.  */
  3333. inspectVerb: deepverb
  3334.     verb = 'inspect' 'examine' 'look at' 'l at' 'x'
  3335.     sdesc = "inspect"
  3336.     doAction = 'Inspect'
  3337.     validDo( actor, obj, seqno ) =
  3338.     {
  3339.         return( obj.isVisible( actor ));
  3340.     }
  3341. ;
  3342. askVerb: deepverb
  3343.     verb = 'ask'
  3344.     sdesc = "ask"
  3345.     prepDefault = aboutPrep
  3346.     ioAction( aboutPrep ) = 'AskAbout'
  3347.     validIo( actor, obj, seqno ) = { return( seqno = 1 ); }
  3348.     validIoList(actor, prep, dobj) = (nil)
  3349. ;
  3350. tellVerb: deepverb
  3351.     verb = 'tell'
  3352.     sdesc = "tell"
  3353.     prepDefault = aboutPrep
  3354.     ioAction( aboutPrep ) = 'TellAbout'
  3355.     validIo( actor, obj, seqno ) = { return( seqno = 1 ); }
  3356.     validIoList(actor, prep, dobj) = (nil)
  3357.     ioDefault( actor, prep ) =
  3358.     {
  3359.         if (prep = aboutPrep)
  3360.         return([]);
  3361.     else
  3362.         return(actor.contents + actor.location.contents);
  3363.     }
  3364. ;
  3365. followVerb: deepverb
  3366.     sdesc = "follow"
  3367.     verb = 'follow'
  3368.     doAction = 'Follow'
  3369. ;
  3370. digVerb: deepverb
  3371.     verb = 'dig' 'dig in'
  3372.     sdesc = "dig in"
  3373.     prepDefault = withPrep
  3374.     ioAction( withPrep ) = 'DigWith'
  3375. ;
  3376. jumpVerb: deepverb
  3377.     verb = 'jump' 'jump over' 'jump off'
  3378.     sdesc = "jump"
  3379.     doAction = 'Jump'
  3380.     action(actor) = { "Wheeee!"; }
  3381. ;
  3382. pushVerb: deepverb
  3383.     verb = 'push' 'press'
  3384.     sdesc = "push"
  3385.     doAction = 'Push'
  3386. ;
  3387. attachVerb: deepverb
  3388.     verb = 'attach' 'connect'
  3389.     sdesc = "attach"
  3390.     prepDefault = toPrep
  3391.     ioAction( toPrep ) = 'AttachTo'
  3392. ;
  3393. wearVerb: deepverb
  3394.     verb = 'wear' 'put on'
  3395.     sdesc = "wear"
  3396.     doAction = 'Wear'
  3397. ;
  3398. dropVerb: deepverb, darkVerb
  3399.     verb = 'drop' 'put down'
  3400.     sdesc = "drop"
  3401.     ioAction( onPrep ) = 'PutOn'
  3402.     doAction = 'Drop'
  3403.     doDefault( actor, prep, io ) =
  3404.     {
  3405.         return( actor.contents );
  3406.     }
  3407. ;
  3408. removeVerb: deepverb
  3409.     verb = 'take off'
  3410.     sdesc = "take off"
  3411.     doAction = 'Unwear'
  3412.     ioAction( fromPrep ) = 'RemoveFrom'
  3413. ;
  3414. openVerb: deepverb
  3415.     verb = 'open'
  3416.     sdesc = "open"
  3417.     doAction = 'Open'
  3418. ;
  3419. closeVerb: deepverb
  3420.     verb = 'close'
  3421.     sdesc = "close"
  3422.     doAction = 'Close'
  3423. ;
  3424. putVerb: deepverb
  3425.     verb = 'put' 'place'
  3426.     sdesc = "put"
  3427.     prepDefault = inPrep
  3428.     ioAction( inPrep ) = 'PutIn'
  3429.     ioAction( onPrep ) = 'PutOn'
  3430.     doDefault( actor, prep, io ) =
  3431.     {
  3432.         return( takeVerb.doDefault( actor, prep, io ) + actor.contents );
  3433.     }
  3434. ;
  3435. takeVerb: deepverb                   // This object defines how to take things
  3436.     verb = 'take' 'pick up' 'get' 'remove'
  3437.     sdesc = "take"
  3438.     ioAction( offPrep ) = 'TakeOff'
  3439.     ioAction( outPrep ) = 'TakeOut'
  3440.     ioAction( fromPrep ) = 'TakeOut'
  3441.     ioAction( inPrep ) = 'TakeOut'
  3442.     ioAction( onPrep ) = 'TakeOff'
  3443.     doAction = 'Take'
  3444.     doDefault( actor, prep, io ) =
  3445.     {
  3446.         local ret, rem, cur, rem2, cur2, tot, i, tot2, j;
  3447.     
  3448.     ret := [];
  3449.         
  3450.     /*
  3451.      *   For "take all out/off of <iobj>", return the (non-fixed)
  3452.      *   contents of the indirect object.  Same goes for "take all in
  3453.      *   <iobj>", "take all on <iobj>", and "take all from <iobj>".
  3454.      */
  3455.     if (( prep=outPrep or prep=offPrep or prep=inPrep or prep=onPrep
  3456.      or prep=fromPrep ) and io<>nil )
  3457.     {
  3458.         rem := io.contents;
  3459.         i := 1;
  3460.         tot := length( rem );
  3461.         while ( i <= tot )
  3462.         {
  3463.             cur := rem[i];
  3464.             if (not cur.isfixed and self.validDo(actor, cur, i))
  3465.             ret += cur;
  3466.         ++i;
  3467.         }
  3468.             return( ret );
  3469.     }
  3470.  
  3471.         /*
  3472.      *   In the general case, return everything that's not fixed
  3473.      *   in the actor's location, or everything inside fixed containers
  3474.      *   that isn't itself fixed.
  3475.      */
  3476.         rem := actor.location.contents;
  3477.     tot := length( rem );
  3478.     i := 1;
  3479.         while ( i <= tot )
  3480.         {
  3481.         cur := rem[i];
  3482.             if ( cur.isfixed )
  3483.             {
  3484.                 if ((( cur.isopenable and cur.isopen ) or
  3485.                   ( not cur.isopenable )) and ( not cur.isactor ))
  3486.                 {
  3487.                     rem2 := cur.contents;
  3488.             tot2 := length( rem2 );
  3489.             j := 1;
  3490.                     while ( j <= tot2 )
  3491.                     {
  3492.                 cur2 := rem2[j];
  3493.                         if ( not cur2.isfixed and not cur2.notakeall )
  3494.             {
  3495.                 ret := ret + cur2;
  3496.             }
  3497.                         j := j + 1;
  3498.                     }
  3499.                 }
  3500.             }
  3501.             else if ( not cur.notakeall )
  3502.         {
  3503.             ret := ret + cur;
  3504.         }
  3505.  
  3506.         i := i + 1;            
  3507.         }
  3508.         return( ret );
  3509.     }
  3510. ;
  3511. plugVerb: deepverb
  3512.     verb = 'plug'
  3513.     sdesc = "plug"
  3514.     prepDefault = inPrep
  3515.     ioAction( inPrep ) = 'PlugIn'
  3516. ;
  3517. lookInVerb: deepverb
  3518.     verb = 'look in' 'look on' 'l in' 'l on'
  3519.     sdesc = "look in"
  3520.     doAction = 'Lookin'
  3521. ;
  3522. screwVerb: deepverb
  3523.     verb = 'screw'
  3524.     sdesc = "screw"
  3525.     ioAction( withPrep ) = 'ScrewWith'
  3526.     doAction = 'Screw'
  3527. ;
  3528. unscrewVerb: deepverb
  3529.     verb = 'unscrew'
  3530.     sdesc = "unscrew"
  3531.     ioAction( withPrep ) = 'UnscrewWith'
  3532.     doAction = 'Unscrew'
  3533. ;
  3534. turnVerb: deepverb
  3535.     verb = 'turn' 'rotate' 'twist'
  3536.     sdesc = "turn"
  3537.     ioAction( toPrep ) = 'TurnTo'
  3538.     ioAction( withPrep ) = 'TurnWith'
  3539.     doAction = 'Turn'
  3540. ;
  3541. switchVerb: deepverb
  3542.     verb = 'switch'
  3543.     sdesc = "switch"
  3544.     doAction = 'Switch'
  3545. ;
  3546. flipVerb: deepverb
  3547.     verb = 'flip'
  3548.     sdesc = "flip"
  3549.     doAction = 'Flip'
  3550. ;
  3551. turnOnVerb: deepverb, darkVerb
  3552.     verb = 'activate' 'turn on' 'switch on'
  3553.     sdesc = "turn on"
  3554.     doAction = 'Turnon'
  3555. ;
  3556. turnOffVerb: deepverb
  3557.     verb = 'turn off' 'deactiv' 'switch off'
  3558.     sdesc = "turn off"
  3559.     doAction = 'Turnoff'
  3560. ;
  3561. lookVerb: deepverb
  3562.     verb = 'look' 'l' 'look around' 'l around'
  3563.     sdesc = "look"
  3564.     action( actor ) =
  3565.     {
  3566.         actor.location.lookAround( true );
  3567.     }
  3568. ;
  3569. sitVerb: deepverb
  3570.     verb = 'sit on' 'sit in' 'sit' 'sit down' 'sit downin' 'sit downon'
  3571.     sdesc = "sit on"
  3572.     doAction = 'Siton'
  3573. ;
  3574. lieVerb: deepverb
  3575.     verb = 'lie' 'lie on' 'lie in' 'lie down' 'lie downon' 'lie downin'
  3576.     sdesc = "lie on"
  3577.     doAction = 'Lieon'
  3578. ;
  3579. getOutVerb: deepverb
  3580.     verb = 'get out' 'get outof' 'get off' 'get offof'
  3581.     sdesc = "get out of"
  3582.     doAction = 'Unboard'
  3583.     action(actor) = { askdo; }
  3584.     doDefault( actor, prep, io ) =
  3585.     {
  3586.         if ( actor.location and actor.location.location )
  3587.             return( [] + actor.location );
  3588.         else return( [] );
  3589.     }
  3590. ;
  3591. boardVerb: deepverb
  3592.     verb = 'get in' 'get into' 'board' 'get on'
  3593.     sdesc = "get on"
  3594.     doAction = 'Board'
  3595. ;
  3596. againVerb: darkVerb         // Required verb:  repeats last command.  No
  3597.                             // action routines are necessary; this one's
  3598.                             // handled internally by the parser.
  3599.     verb = 'again' 'g'
  3600. ;
  3601. waitVerb: darkVerb
  3602.     verb = 'wait' 'z'
  3603.     action( actor ) =
  3604.     {
  3605.         "Time passes...\n";
  3606.     }
  3607. ;
  3608. iVerb: deepverb
  3609.     verb = 'inventory' 'i'
  3610.     action( actor ) =
  3611.     {
  3612.         if (length( actor.contents ))
  3613.         {
  3614.             "%You% %have% "; listcont( actor ); ". ";
  3615.             listcontcont( actor );
  3616.         }
  3617.     else
  3618.             "%You% %are% empty-handed.\n";
  3619.     }
  3620. ;
  3621. lookThruVerb: deepverb
  3622.     verb = 'look through' 'look thru' 'l through' 'l thru'
  3623.     sdesc = "look through"
  3624.     doAction = 'Lookthru'
  3625. ;
  3626. breakVerb: deepverb
  3627.     verb = 'break' 'ruin' 'destroy'
  3628.     sdesc = "break"
  3629.     doAction = 'Break'
  3630. ;
  3631. attackVerb: deepverb
  3632.     verb = 'attack' 'kill' 'hit'
  3633.     sdesc = "attack"
  3634.     prepDefault = withPrep
  3635.     ioAction( withPrep ) = 'AttackWith'
  3636. ;
  3637. climbVerb: deepverb
  3638.     verb = 'climb'
  3639.     sdesc = "climb"
  3640.     doAction = 'Climb'
  3641. ;
  3642. eatVerb: deepverb
  3643.     verb = 'eat' 'consume'
  3644.     sdesc = "eat"
  3645.     doAction = 'Eat'
  3646. ;
  3647. drinkVerb: deepverb
  3648.     verb = 'drink'
  3649.     sdesc = "drink"
  3650.     doAction = 'Drink'
  3651. ;
  3652. giveVerb: deepverb
  3653.     verb = 'give' 'offer'
  3654.     sdesc = "give"
  3655.     prepDefault = toPrep
  3656.     ioAction( toPrep ) = 'GiveTo'
  3657.     doDefault( actor, prep, io ) =
  3658.     {
  3659.         return( actor.contents );
  3660.     }
  3661. ;
  3662. pullVerb: deepverb
  3663.     verb = 'pull'
  3664.     sdesc = "pull"
  3665.     doAction = 'Pull'
  3666. ;
  3667. readVerb: deepverb
  3668.     verb = 'read'
  3669.     sdesc = "read"
  3670.     doAction = 'Read'
  3671. ;
  3672. throwVerb: deepverb
  3673.     verb = 'throw' 'toss'
  3674.     sdesc = "throw"
  3675.     prepDefault = atPrep
  3676.     ioAction( atPrep ) = 'ThrowAt'
  3677.     ioAction( toPrep ) = 'ThrowTo'
  3678. ;
  3679. standOnVerb: deepverb
  3680.     verb = 'stand on'
  3681.     sdesc = "stand on"
  3682.     doAction = 'Standon'
  3683. ;
  3684. standVerb: deepverb
  3685.     verb = 'stand' 'stand up' 'get up'
  3686.     sdesc = "stand"
  3687.     action( actor ) =
  3688.     {
  3689.         if ( actor.location=nil or actor.location.location = nil )
  3690.             "%You're% already standing! ";
  3691.         else
  3692.         {
  3693.         actor.location.doUnboard( actor );
  3694.         }
  3695.     }
  3696. ;
  3697. helloVerb: deepverb
  3698.     verb = 'hello' 'hi' 'greetings'
  3699.     action( actor ) =
  3700.     {
  3701.         "Nice weather we've been having.\n";
  3702.     }
  3703. ;
  3704. showVerb: deepverb
  3705.     verb = 'show'
  3706.     sdesc = "show"
  3707.     prepDefault = toPrep
  3708.     ioAction( toPrep ) = 'ShowTo'
  3709.     doDefault( actor, prep, io ) =
  3710.     {
  3711.         return( actor.contents );
  3712.     }
  3713. ;
  3714. cleanVerb: deepverb
  3715.     verb = 'clean'
  3716.     sdesc = "clean"
  3717.     ioAction( withPrep ) = 'CleanWith'
  3718.     doAction = 'Clean'
  3719. ;
  3720. sayVerb: deepverb
  3721.     verb = 'say'
  3722.     sdesc = "say"
  3723.     doAction = 'Say'
  3724. ;
  3725. yellVerb: deepverb
  3726.     verb = 'yell' 'shout' 'yell at' 'shout at'
  3727.     action( actor ) =
  3728.     {
  3729.         "%Your% throat is a bit sore now. ";
  3730.     }
  3731. ;
  3732. moveVerb: deepverb
  3733.     verb = 'move'
  3734.     sdesc = "move"
  3735.     ioAction( withPrep ) = 'MoveWith'
  3736.     ioAction( toPrep ) = 'MoveTo'
  3737.     doAction = 'Move'
  3738. ;
  3739. fastenVerb: deepverb
  3740.     verb = 'fasten' 'buckle' 'buckle up'
  3741.     sdesc = "fasten"
  3742.     doAction = 'Fasten'
  3743. ;
  3744. unfastenVerb: deepverb
  3745.     verb = 'unfasten' 'unbuckle'
  3746.     sdesc = "unfasten"
  3747.     doAction = 'Unfasten'
  3748. ;
  3749. unplugVerb: deepverb
  3750.     verb = 'unplug'
  3751.     sdesc = "unplug"
  3752.     ioAction( fromPrep ) = 'UnplugFrom'
  3753.     doAction = 'Unplug'
  3754. ;
  3755. lookUnderVerb: deepverb
  3756.     verb = 'look under' 'look beneath' 'l under' 'l beneath'
  3757.     sdesc = "look under"
  3758.     doAction = 'Lookunder'
  3759. ;
  3760. lookBehindVerb: deepverb
  3761.     verb = 'look behind' 'l behind'
  3762.     sdesc = "look behind"
  3763.     doAction = 'Lookbehind'
  3764. ;
  3765. typeVerb: deepverb
  3766.     verb = 'type'
  3767.     sdesc = "type"
  3768.     prepDefault = onPrep
  3769.     ioAction( onPrep ) = 'TypeOn'
  3770. ;
  3771. lockVerb: deepverb
  3772.     verb = 'lock'
  3773.     sdesc = "lock"
  3774.     ioAction( withPrep ) = 'LockWith'
  3775.     doAction = 'Lock'
  3776.     prepDefault = withPrep
  3777. ;
  3778. unlockVerb: deepverb
  3779.     verb = 'unlock'
  3780.     sdesc = "unlock"
  3781.     ioAction( withPrep ) = 'UnlockWith'
  3782.     doAction = 'Unlock'
  3783.     prepDefault = withPrep
  3784. ;
  3785. detachVerb: deepverb
  3786.     verb = 'detach' 'disconnect'
  3787.     prepDefault = fromPrep
  3788.     ioAction( fromPrep ) = 'DetachFrom'
  3789.     doAction = 'Detach'
  3790.     sdesc = "detach"
  3791. ;
  3792. sleepVerb: darkVerb
  3793.     action( actor ) =
  3794.     {
  3795.         if ( actor.cantSleep )
  3796.             "%You% %are% much too anxious worrying about %your% continued
  3797.             survival to fall asleep now. ";
  3798.         else if ( global.awakeTime+1 < global.sleepTime )
  3799.             "%You're% not tired. ";
  3800.         else if ( not ( actor.location.isbed or actor.location.ischair ))
  3801.             "I don't know about you, but I can never sleep
  3802.             standing up. %You% should find a nice comfortable
  3803.             bed somewhere. ";
  3804.         else
  3805.         {
  3806.             "%You% quickly drift%s% off into dreamland...\b";
  3807.             goToSleep();
  3808.         }
  3809.     }
  3810.     verb = 'sleep'
  3811. ;
  3812. pokeVerb: deepverb
  3813.     verb = 'poke' 'jab'
  3814.     sdesc = "poke"
  3815.     doAction = 'Poke'
  3816. ;
  3817. touchVerb: deepverb
  3818.     verb = 'touch'
  3819.     sdesc = "touch"
  3820.     doAction = 'Touch'
  3821. ;
  3822. moveNVerb: deepverb
  3823.     verb = 'move north' 'move n' 'push north' 'push n'
  3824.     sdesc = "move north"
  3825.     doAction = 'MoveN'
  3826. ;
  3827. moveSVerb: deepverb
  3828.     verb = 'move south' 'move s' 'push south' 'push s'
  3829.     sdesc = "move south"
  3830.     doAction = 'MoveS'
  3831. ;
  3832. moveEVerb: deepverb
  3833.     verb = 'move east' 'move e' 'push east' 'push e'
  3834.     sdesc = "move east"
  3835.     doAction = 'MoveE'
  3836. ;
  3837. moveWVerb: deepverb
  3838.     verb = 'move west' 'move w' 'push west' 'push w'
  3839.     sdesc = "move west"
  3840.     doAction = 'MoveW'
  3841. ;
  3842. moveNEVerb: deepverb
  3843.     verb = 'move northeast' 'move ne' 'push northeast' 'push ne'
  3844.     sdesc = "move northeast"
  3845.     doAction = 'MoveNE'
  3846. ;
  3847. moveNWVerb: deepverb
  3848.     verb = 'move northwest' 'move nw' 'push northwest' 'push nw'
  3849.     sdesc = "move northwest"
  3850.     doAction = 'MoveNW'
  3851. ;
  3852. moveSEVerb: deepverb
  3853.     verb = 'move southeast' 'move se' 'push southeast' 'push se'
  3854.     sdesc = "move southeast"
  3855.     doAction = 'MoveSE'
  3856. ;
  3857. moveSWVerb: deepverb
  3858.     verb = 'move southwest' 'move sw' 'push southwest' 'push sw'
  3859.     sdesc = "move southwest"
  3860.     doAction = 'MoveSW'
  3861. ;
  3862. centerVerb: deepverb
  3863.     verb = 'center'
  3864.     sdesc = "center"
  3865.     doAction = 'Center'
  3866. ;
  3867. searchVerb: deepverb
  3868.     verb = 'search'
  3869.     sdesc = "search"
  3870.     doAction = 'Search'
  3871. ;
  3872.  
  3873. /*
  3874.  *   Travel verbs  - these verbs allow the player to move about.
  3875.  *   All travel verbs have the property isTravelVerb set true.
  3876.  */
  3877. class travelVerb: deepverb, darkVerb
  3878.     isTravelVerb = true
  3879. ;
  3880.  
  3881. eVerb: travelVerb
  3882.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3883.     verb = 'e' 'east' 'go east'
  3884.     travelDir( actor ) = { return( actor.location.east ); }
  3885. ;
  3886. sVerb: travelVerb
  3887.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3888.     verb = 's' 'south' 'go south'
  3889.     travelDir( actor ) = { return( actor.location.south ); }
  3890. ;
  3891. nVerb: travelVerb
  3892.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3893.     verb = 'n' 'north' 'go north'
  3894.     travelDir( actor ) = { return( actor.location.north ); }
  3895. ;
  3896. wVerb: travelVerb
  3897.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3898.     verb = 'w' 'west' 'go west'
  3899.     travelDir( actor ) = { return( actor.location.west ); }
  3900. ;
  3901. neVerb: travelVerb
  3902.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3903.     verb = 'ne' 'northeast' 'go ne' 'go northeast'
  3904.     travelDir( actor ) = { return( actor.location.ne ); }
  3905. ;
  3906. nwVerb: travelVerb
  3907.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3908.     verb = 'nw' 'northwest' 'go nw' 'go northwest'
  3909.     travelDir( actor ) = { return( actor.location.nw ); }
  3910. ;
  3911. seVerb: travelVerb
  3912.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3913.     verb = 'se' 'southeast' 'go se' 'go southeast'
  3914.     travelDir( actor ) = { return( actor.location.se ); }
  3915. ;
  3916. swVerb: travelVerb
  3917.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3918.     verb = 'sw' 'southwest' 'go sw' 'go southwest'
  3919.     travelDir( actor ) = { return( actor.location.sw ); }
  3920. ;
  3921. inVerb: travelVerb
  3922.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3923.     verb = 'in' 'go in' 'enter'
  3924.     sdesc = "enter"
  3925.     doAction = 'Enter'
  3926.     travelDir( actor ) = { return( actor.location.in ); }
  3927.     ioAction(onPrep) = 'EnterOn'
  3928.     ioAction(inPrep) = 'EnterIn'
  3929.     ioAction(withPrep) = 'EnterWith'
  3930. ;
  3931. outVerb: travelVerb
  3932.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3933.     verb = 'out' 'go out' 'exit' 'leave'
  3934.     travelDir( actor ) = { return( actor.location.out ); }
  3935. ;
  3936. dVerb: travelVerb
  3937.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3938.     verb = 'd' 'down' 'go down'
  3939.     travelDir( actor ) = { return( actor.location.down ); }
  3940. ;
  3941. uVerb: travelVerb
  3942.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3943.     verb = 'u' 'up' 'go up'
  3944.     travelDir( actor ) = { return( actor.location.up ); }
  3945. ;
  3946.  
  3947. /*
  3948.  *   sysverb:  A system verb.  Verbs of this class are special verbs that
  3949.  *   can be executed without certain normal validations.  For example,
  3950.  *   a system verb can be executed in a dark room.  System verbs are
  3951.  *   for operations such as saving, restoring, and quitting, which are
  3952.  *   not really part of the game.
  3953.  */
  3954. class sysverb: deepverb, darkVerb
  3955.     issysverb = true
  3956. ;
  3957.  
  3958. quitVerb: sysverb
  3959.     verb = 'quit'
  3960.     quitGame(actor) =
  3961.     {
  3962.         local yesno;
  3963.  
  3964.         scoreRank();
  3965.         "\bDo you really want to quit? (YES or NO) > ";
  3966.         yesno := yorn();
  3967.         "\b";
  3968.         if ( yesno = 1 )
  3969.         {
  3970.             terminate();    // allow user good-bye message
  3971.         quit();
  3972.         }
  3973.         else
  3974.         {
  3975.             "Okay. ";
  3976.         }
  3977.     }
  3978.     action( actor ) =
  3979.     {
  3980.     self.quitGame(actor);
  3981.     abort;
  3982.     }
  3983. ;
  3984. verboseVerb: sysverb
  3985.     verb = 'verbose'
  3986.     verboseMode(actor) =
  3987.     {
  3988.         "Okay, now in VERBOSE mode.\n";
  3989.         global.verbose := true;
  3990.     Me.location.lookAround( true );
  3991.     }
  3992.     action( actor ) =
  3993.     {
  3994.     self.verboseMode(actor);
  3995.     abort;
  3996.     }
  3997. ;
  3998. terseVerb: sysverb
  3999.     verb = 'brief' 'terse'
  4000.     terseMode(actor) =
  4001.     {
  4002.         "Okay, now in TERSE mode.\n";
  4003.         global.verbose := nil;
  4004.     }
  4005.     action( actor ) =
  4006.     {
  4007.     self.terseMode(actor);
  4008.     abort;
  4009.     }
  4010. ;
  4011. scoreVerb: sysverb
  4012.     verb = 'score' 'status'
  4013.     showScore(actor) =
  4014.     {
  4015.         scoreRank();
  4016.     }
  4017.     action( actor ) =
  4018.     {
  4019.     self.showScore(actor);
  4020.     abort;
  4021.     }
  4022. ;
  4023. saveVerb: sysverb
  4024.     verb = 'save'
  4025.     sdesc = "save"
  4026.     doAction = 'Save'
  4027.     saveGame(actor) =
  4028.     {
  4029.         local savefile;
  4030.     
  4031.     savefile := askfile( 'File to save game in' );
  4032.     if ( savefile = nil or savefile = '' )
  4033.         {
  4034.         "Failed. ";
  4035.             return nil;
  4036.     }
  4037.     else if (save( savefile ))
  4038.         {
  4039.         "Saved failed. ";
  4040.             return nil;
  4041.     }
  4042.     else
  4043.     {
  4044.         "Saved. ";
  4045.             return true;
  4046.     }
  4047.     }
  4048.     action( actor ) =
  4049.     {
  4050.     self.saveGame(actor);
  4051.     abort;
  4052.     }
  4053. ;
  4054. restoreVerb: sysverb
  4055.     verb = 'restore'
  4056.     sdesc = "restore"
  4057.     doAction = 'Restore'
  4058.     restoreGame(actor) =
  4059.     {
  4060.         local savefile;
  4061.     
  4062.     savefile := askfile( 'File to restore game from' );
  4063.     if ( savefile = nil or savefile = '' )
  4064.         {
  4065.         "Failed. ";
  4066.             return nil;
  4067.     }
  4068.     else if (restore( savefile ))
  4069.         {
  4070.         "Restore failed. ";
  4071.             return nil;
  4072.     }
  4073.     else
  4074.     {
  4075.         scoreStatus(global.score, global.turnsofar);
  4076.         "Restored.\b";
  4077.         Me.location.lookAround(true);
  4078.         return true;
  4079.     }
  4080.     }
  4081.     action( actor ) =
  4082.     {
  4083.     self.restoreGame(actor);
  4084.     abort;
  4085.     }
  4086. ;
  4087. scriptVerb: sysverb
  4088.     verb = 'script'
  4089.     doAction = 'Script'
  4090.     startScripting(actor) =
  4091.     {
  4092.         local scriptfile;
  4093.     
  4094.     scriptfile := askfile( 'File to write transcript to' );
  4095.     if ( scriptfile = nil or scriptfile = '' )
  4096.         "Failed. ";
  4097.     else
  4098.     {
  4099.         logging( scriptfile );
  4100.         "All text will now be saved to the script file.
  4101.             Type UNSCRIPT at any time to discontinue scripting.";
  4102.     }
  4103.     }
  4104.     action( actor ) =
  4105.     {
  4106.     self.startScripting(actor);
  4107.     abort;
  4108.     }
  4109. ;
  4110. unscriptVerb: sysverb
  4111.     verb = 'unscript'
  4112.     stopScripting(actor) =
  4113.     {
  4114.         logging( nil );
  4115.         "Script closed.\n";
  4116.     }
  4117.     action( actor ) =
  4118.     {
  4119.     self.stopScripting(actor);
  4120.         abort;
  4121.     }
  4122. ;
  4123. restartVerb: sysverb
  4124.     verb = 'restart'
  4125.     restartGame(actor) =
  4126.     {
  4127.         local yesno;
  4128.         while ( true )
  4129.         {
  4130.             "Are you sure you want to start over? (YES or NO) > ";
  4131.             yesno := yorn();
  4132.             if ( yesno = 1 )
  4133.             {
  4134.                 "\n";
  4135.         scoreStatus(0, 0);
  4136.                 restart(initRestart, global.initRestartParam);
  4137.                 break;
  4138.             }
  4139.             else if ( yesno = 0 )
  4140.             {
  4141.                 "\nOkay.\n";
  4142.         break;
  4143.             }
  4144.         }
  4145.     }
  4146.     action( actor ) =
  4147.     {
  4148.     self.restartGame(actor);
  4149.     abort;
  4150.     }
  4151. ;
  4152. versionVerb: sysverb
  4153.     verb = 'version'
  4154.     showVersion(actor) =
  4155.     {
  4156.         version.sdesc;
  4157.     }
  4158.     action( actor ) =
  4159.     {
  4160.     self.showVersion(actor);
  4161.         abort;
  4162.     }
  4163. ;
  4164. debugVerb: sysverb
  4165.     verb = 'debug'
  4166.     enterDebugger(actor) =
  4167.     {
  4168.     if (debugTrace())
  4169.         "You can't think this game has any bugs left in it... ";
  4170.     }
  4171.     action( actor ) =
  4172.     {
  4173.     self.enterDebugger(actor);
  4174.     abort;
  4175.     }
  4176. ;
  4177.  
  4178. undoVerb: sysverb
  4179.     verb = 'undo'
  4180.     undoMove(actor) =
  4181.     {
  4182.     /* do TWO undo's - one for this 'undo', one for previous command */
  4183.     if (undo() and undo())
  4184.     {
  4185.         "(Undoing one command)\b";
  4186.         Me.location.lookAround(true);
  4187.         scoreStatus(global.score, global.turnsofar);
  4188.     }
  4189.     else
  4190.         "No more undo information is available. ";
  4191.     }
  4192.     action(actor) =
  4193.     {
  4194.     self.undoMove(actor);
  4195.     abort;
  4196.     }
  4197. ;
  4198.  
  4199. /*
  4200.  *  Prep: object
  4201.  *
  4202.  *  A preposition.  The preposition property specifies the
  4203.  *  vocabulary word.
  4204.  */
  4205. class Prep: object
  4206. ;
  4207.  
  4208. /*
  4209.  *   Various prepositions
  4210.  */
  4211. ofPrep: Prep
  4212.     preposition = 'of'
  4213.     sdesc = "of"
  4214. ;
  4215. aboutPrep: Prep
  4216.     preposition = 'about'
  4217.     sdesc = "about"
  4218. ;
  4219. withPrep: Prep
  4220.     preposition = 'with'
  4221.     sdesc = "with"
  4222. ;
  4223. toPrep: Prep
  4224.     preposition = 'to'
  4225.     sdesc = "to"
  4226. ;
  4227. onPrep: Prep
  4228.     preposition = 'on' 'onto' 'downon' 'upon'
  4229.     sdesc = "on"
  4230. ;
  4231. inPrep: Prep
  4232.     preposition = 'in' 'into' 'downin'
  4233.     sdesc = "in"
  4234. ;
  4235. offPrep: Prep
  4236.     preposition = 'off' 'offof'
  4237.     sdesc = "off"
  4238. ;
  4239. outPrep: Prep
  4240.     preposition = 'out' 'outof'
  4241.     sdesc = "out"
  4242. ;
  4243. fromPrep: Prep
  4244.     preposition = 'from'
  4245.     sdesc = "from"
  4246. ;
  4247. betweenPrep: Prep
  4248.     preposition = 'between' 'inbetween'
  4249.     sdesc = "between"
  4250. ;
  4251. overPrep: Prep
  4252.     preposition = 'over'
  4253.     sdesc = "over"
  4254. ;
  4255. atPrep: Prep
  4256.     preposition = 'at'
  4257.     sdesc = "at"
  4258. ;
  4259. aroundPrep: Prep
  4260.     preposition = 'around'
  4261.     sdesc = "around"
  4262. ;
  4263. thruPrep: Prep
  4264.     preposition = 'through' 'thru'
  4265.     sdesc = "through"
  4266. ;
  4267. dirPrep: Prep
  4268.     preposition = 'north' 'south' 'east' 'west' 'up' 'down' 'northeast' 'ne'
  4269.                   'northwest' 'nw' 'southeast' 'se' 'southwest' 'sw'
  4270.     sdesc = "north"         // Shouldn't ever need this, but just in case
  4271. ;
  4272. underPrep: Prep
  4273.     preposition = 'under' 'beneath'
  4274.     sdesc = "under"
  4275. ;
  4276. behindPrep: Prep
  4277.     preposition = 'behind'
  4278.     sdesc = "behind"
  4279. ;
  4280.  
  4281. /*
  4282.  *   articles:  the "built-in" articles.  "The," "a," and "an" are
  4283.  *   defined.
  4284.  */
  4285. articles: object
  4286.     article = 'the' 'a' 'an'
  4287. ;
  4288.  
  4289.